logo
podcast Podcast
get help Get Unstuck

Quickly attach a Docker terminal in PhpStorm

I love keeping my hands on the keyboard

Joel Clermont
Joel Clermont
2025-02-21

We typically use Docker for our development environments, and PHPStorm has some great Docker integrations.

For example, I can see my running containers for the current project, view the combined log output across containers, and open a terminal within a specific container.

That last task is key, because when I run composer or artisan it needs to run inside the container to make sure the PHP version, set of extensions, and so on, is as expected.

Lately, I've been feeling the slightest bit of friction having to open that Docker services panel, expand the Docker compose project, and then right-clicking the container to launch a terminal. I decided it was time to find a way to do this more quickly, and strictly from the keyboard.

But then I realized that all I really need is a second terminal tab in my main terminal. From the default PHPStorm terminal, I can run docker compose exec app sh and I get the attached terminal running inside the container.

(As a side note, we call our php-fpm container app across all our projects, so no project-specific configuration needed here.)

Even better, I already have a keyboard shortcut to open the terminal, so the muscle memory is already there. Problem solved!

Here to help,

Joel

P.S. Would you like a set of Laravel experts to review your code and give suggestions where you can improve? Schedule a call to get started.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.