Using Docker Logs, Processes and Services Directly from PhpStorm
AI generated
IDE
{ }
PhpStorm · Docker · Services · Logs
Using Docker Logs, Processes and Services
Directly from PhpStorm

Anyone who switches to the terminal for every docker logs call loses time and context. PhpStorm ships with a complete Docker integration: log streaming, service control, process inspection and a remote interpreter, all without ever leaving the IDE.

12 min read Docker · Docker Compose · Remote Interpreter · Services Tool Window PhpStorm 2024.x · 2025.x

1. Why Docker integration in the IDE beats the terminal

The classic way of working with Docker looks like this: a terminal window runs permanently next to the IDE, several docker logs -f processes run in parallel, and as soon as a problem appears you switch back and forth between IDE and terminal. That context switch does not just cost time, it interrupts the flow of thought while debugging. This is exactly where PhpStorm's Docker integration comes in.

PhpStorm has offered a full Docker integration for several versions now, one that goes far beyond a simple log viewer window. Containers can be started, stopped and restarted, logs stream in real time with search and filter functions, running processes can be inspected, and shells can be opened directly from the IDE. Anyone who uses this integration consistently reduces the number of open terminal windows to a minimum and works with far fewer interruptions.

The difference is especially noticeable in projects with Docker Compose and multiple services, typical for Magento 2, WordPress Multisite or Symfony applications. Instead of juggling five parallel docker logs -f processes, you see all service logs laid out side by side in the Services tool window and can switch between them in seconds.

2. Setting up the Docker connection in PhpStorm

Setup begins under Settings → Build, Execution, Deployment → Docker. On Linux and macOS, PhpStorm automatically detects the Unix socket unix:///var/run/docker.sock, which is correct for most default installations. For remote Docker hosts or TCP connections you enter the URL in the format tcp://hostname:2376. For TLS-secured connections you provide the certificate, key and CA directly in the configuration.

After saving the connection, PhpStorm shows a green connection indicator. In the Services tool window (View → Tool Windows → Services or Alt+8), the connection appears under the Docker node with all running containers, available images and networks. Connection settings are stored per project and can be shared with the team via the Settings Repository plugin.

One important detail for Mark Shust's Docker Magento setup and similar setups: if the Docker socket is redirected through a proxy or a bridge, the socket path must be adjusted accordingly. With Rancher Desktop, for example, the socket is often located at a different path than the default. PhpStorm shows directly in the connection dialog whether the connection succeeded, and gives meaningful hints when it fails.

3. The Services tool window: overview and navigation

The Services tool window is the central tool for the Docker integration. It is organized into several areas: Containers shows all running and stopped containers with status, image, ports and creation time. Images lists downloaded images with tags and sizes. Networks and volumes round out the picture. Right-clicking a container opens a context menu with all the essential actions: start, stop, restart, remove, show logs and open shell.

For Docker Compose projects, the Services tool window groups containers by compose file and service name. The compose node has its own actions such as "Up", "Down", "Pull" and "Build" that act directly on the compose file. This structuring makes it easy to quickly find the right container in a project with eight compose services, without reading long lists of container IDs.

The pinning feature in the Services tool window lets you pin frequently needed containers or compose projects to the top. Entries can be reordered via drag and drop. PhpStorm also remembers which log tabs were open and restores them after an IDE restart, a small detail with a big practical payoff during long debugging sessions.

4. Streaming and filtering container logs live

Double-clicking a container, or clicking "Show Logs", opens a dedicated log tab in the Services tool window. The log stream runs in real time, with automatic scrolling to the end. In the top right there is a search bar that searches the entire log buffer, with regex support. That lets you filter for specific request IDs, error messages or timestamps in the middle of a running log stream without interrupting it.

Particularly handy: PhpStorm automatically colors lines by log level once the format is recognized. Lines containing "ERROR" or "CRITICAL" appear red, warnings appear orange. This visual distinction speeds up orientation in large logs considerably. The gear icon exposes options such as "Show timestamps", "Show stderr separately" and "Wrap lines".

For projects with multiple services, several log tabs can be open at the same time. PhpStorm manages each as its own tab in the Services window, enabling direct side by side monitoring. Logs can be exported to a file via "Save to File", useful for bug reports or sharing with colleagues who have no access to the Docker host.


# docker-compose.yml (structured logging for PhpStorm log parsing)
version: "3.9"

services:
  php-fpm:
    image: markoshust/magento-php:8.4-fpm
    volumes:
      - .:/var/www/html
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "5"
        labels: "service=php-fpm,env=development"
    environment:
      PHP_IDE_CONFIG: "serverName=mironsoft-docker"

  nginx:
    image: markoshust/magento-nginx:1.24
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "5"

  mysql:
    image: mariadb:10.6
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "3"

5. Inspecting processes inside a container

Through the "Processes" tab in the Services tool window, PhpStorm shows a live view of all processes running inside the selected container, similar to docker top, but interactive. You see PID, user, CPU and memory usage as well as the full command. Clicking "Kill Process" sends SIGTERM or SIGKILL directly to the process inside the container, without opening a terminal.

This feature is especially valuable when PHP-FPM workers hang or a cron job puts the container under load. Instead of working with docker exec php-fpm ps aux, you see the process list updated live. Zombie processes, stuck database connections or worker pools growing out of control become immediately visible. In everyday debugging this saves several steps compared to a purely terminal-based workflow.

A complementary feature is "Open Terminal" directly from the container context menu. PhpStorm then opens an interactive shell inside the container as a new tab in the integrated terminal. This shell runs with the same user context as the container, an important detail when file permissions or environment variables matter. Anyone who regularly opens shells inside containers can automate this further via a dedicated run configuration.

6. Controlling Docker Compose services

PhpStorm automatically detects Docker Compose files in the project and offers direct integration in the Services tool window. Via "Add Service → Docker Compose" you select the compose.yaml and optionally configure a profile or specific services. The node then appears in the Services tree and shows all defined services with their current status.

The actions "Compose Up", "Compose Down", "Compose Pull" and "Compose Build" are available by right-clicking the compose node. "Compose Up" starts all services in the background and automatically opens log tabs for all started containers. "Compose Down" stops and removes containers, and with the "--volumes" option also removes the volumes. These actions correspond exactly to the CLI commands, but are integrated directly into the development workflow.

A particularly useful feature: individual services can be restarted by right-clicking the service node, without stopping the entire compose environment. This is frequently needed during development, for example when the PHP-FPM configuration has changed or an Nginx reload is required. PhpStorm makes sure that dependent services are not interrupted in the process.


# .idea/workspace.xml (PhpStorm Docker Compose run configuration, auto-generated)
# This shows what PhpStorm stores when you configure Docker Compose services

<!--
<component name="RunManager">
  <configuration name="docker-compose: Up" type="docker-deploy" factoryName="docker-compose">
    <deployment type="docker-compose">
      <settings>
        <option name="sourceFilePath" value="compose.yaml" />
        <option name="services">
          <list>
            <option value="php-fpm" />
            <option value="nginx" />
            <option value="db" />
          </list>
        </option>
        <option name="removeOrphans" value="true" />
        <option name="forceRecreate" value="false" />
      </settings>
    </deployment>
  </configuration>
</component>
-->

# Equivalent CLI command PhpStorm executes:
# docker compose -f compose.yaml up -d php-fpm nginx db --remove-orphans

7. Configuring a remote PHP interpreter via Docker

A remote PHP interpreter via Docker lets PhpStorm run PHP code directly inside the container, for tests, linting and code analysis. Configuration happens under Settings → PHP → CLI Interpreter → + → From Docker, Vagrant, VM, WSL. You select the Docker connection type, then the image or the service from the compose file. PhpStorm then starts a temporary container, reads the PHP version and installed extensions, and stores this information for later use.

With the remote interpreter configured, PhpStorm runs composer commands, PHPUnit tests and PHPStan analyses directly inside the container. That means no manual PHP installation on the host, no version conflicts, and tests run in exactly the same environment as production. Run configurations for PHPUnit can point to the remote interpreter and start tests with a single click.

For projects such as Magento 2, the remote interpreter configuration is especially valuable because Magento requires specific PHP extensions such as sodium, gd and bcmath. A locally installed PHP without these extensions would fail immediately when running Magento tests. With the Docker interpreter, the extension configuration matches automatically because the same image is used as in the development environment.

8. Connecting run configurations to Docker

PhpStorm run configurations can be connected directly to Docker, so that clicking "Run" or "Debug" automatically starts the container, executes the code and displays the output in the IDE. Under "Add New Configuration → Docker → Docker Image" or "Docker Compose" you can configure container start parameters, environment variables, volumes and ports. These configurations can be checked in as XML in the .idea/ directory and shared with the team.

A typical run configuration for Magento 2 would reference the PHP-FPM container and run bin/magento cache:flush or bin/magento indexer:reindex. Instead of typing these commands into the terminal, you can save them as named run configurations and invoke them via the Run menu or a keyboard shortcut. PhpStorm shows the output directly in the run window and marks successful or failed executions in color.

It gets even more powerful in combination with the debugger: a debug run configuration starts the container with Xdebug enabled, waits for the IDE connection and automatically pauses at configured breakpoints. The entire debug workflow, starting a container, setting a breakpoint, triggering a request, inspecting variables, runs in a single IDE session without switching to a terminal.


<?php
// PHP remote interpreter check (run inside PhpStorm terminal, Docker container)
// This shows how PhpStorm validates the interpreter configuration

// PhpStorm executes this automatically when configuring remote interpreter:
// docker run --rm markoshust/magento-php:8.4-fpm php -r "
//   echo PHP_VERSION . PHP_EOL;
//   echo implode(', ', get_loaded_extensions()) . PHP_EOL;
// "

// Expected output for Magento 2 compatibility:
// 8.4.x
// Core, date, libxml, openssl, pcre, zlib, filter, hash, json,
// mbstring, SPL, PDO, bcmath, calendar, ctype, curl, dom, exif,
// fileinfo, ftp, gd, gettext, intl, pdo_mysql, Phar, posix,
// readline, Reflection, session, SimpleXML, soap, sodium, sockets,
// standard, tokenizer, xml, xmlreader, xmlwriter, xsl, zip

// PhpStorm run config to flush Magento cache via Docker exec:
// Command: docker compose exec php-fpm bin/magento cache:flush
// Working dir: /var/www/html

9. IDE integration versus terminal compared

The direct comparison shows where PhpStorm's Docker integration outperforms a pure terminal workflow, and where the terminal is still the better choice.

Task Terminal way PhpStorm Docker integration Advantage
Following logs docker logs -f container Services window → log tab Colored, searchable, no terminal switch
Restarting a container docker restart name Right-click → Restart Context menu, no typo in the name
Running PHP tests docker exec php phpunit Run config with remote interpreter Results in test runner, click through to error
Opening a shell docker exec -it php bash Services → Open Terminal Directly in the IDE terminal, no extra window
Viewing processes docker top container Services → Processes tab Live update, kill button directly available

The terminal remains the better choice for complex one-off commands, scripting and situations where pipe chains or several consecutive commands are typed faster than they would be configured. PhpStorm's Docker integration shines at recurring tasks in everyday development: log monitoring, service management and running tests and analysis tools with always the same parameters.

Mironsoft

Magento 2 development with professional Docker and PhpStorm infrastructure

Want a professionally set up Docker development environment?

We set up Docker environments for Magento 2, configure PhpStorm end to end, from remote interpreter to Xdebug, and train your team in productive use of the IDE Docker integration.

Docker setup

Mark Shust Docker Magento configuration with PhpStorm integration and Xdebug

IDE configuration

Fully set up remote interpreter, run configs and Docker Services window

Team onboarding

Document and train a consistent development environment for the whole team

10. Summary

PhpStorm's Docker integration is not a comfort feature, it is a serious productivity tool for the daily development workflow. The Services tool window centralizes container management, log monitoring and process inspection in a single, searchable interface. Docker Compose projects can be started, stopped and rebuilt without switching to a terminal. Remote PHP interpreters run tests and analysis tools directly inside the container and eliminate version conflicts between host and container.

The biggest win lies in the reduced context switching. Anyone who no longer has to jump back and forth between IDE and terminal to check logs or restart a container stays in the development flow. Run configurations store recurring Docker commands as named actions and make them reachable via keyboard shortcut. For teams, checked-in .idea/ configurations enable a consistent development environment without elaborate onboarding documentation.

Docker integration in PhpStorm, the essentials at a glance

Setting up the connection

Settings → Build, Execution, Deployment → Docker. Unix socket is detected automatically. Open the Services tool window with Alt+8.

Logs and processes

Double-clicking a container opens a log tab with real-time streaming, regex search and automatic coloring by log level.

Remote interpreter

Settings → PHP → CLI Interpreter → Docker. PHPUnit, PHPStan and Composer run directly inside the container, no local PHP installation needed.

Run configurations

Save Docker Compose Up/Down as a run config, check it into the .idea/ directory and share it with the team for a consistent development environment.

11. FAQ: Docker Integration in PhpStorm

1How do I connect PhpStorm to Docker?
Settings → Build, Execution, Deployment → Docker. Unix socket is detected automatically on Linux/macOS. Open the Services tool window with Alt+8.
2Can PhpStorm control Docker Compose directly?
Yes. Services window → Add Service → Docker Compose. Compose Up, Down, Build via right-click. Individual services can be restarted separately.
3What is a remote PHP interpreter?
PHP runs directly inside the Docker container. PHPUnit, Composer, PHPStan, all inside the container without a local PHP installation. Configuration: Settings → PHP → CLI Interpreter → Docker.
4How do I stream container logs in PhpStorm?
Double-click the container in the Services window, the log tab opens. Real-time streaming with regex search and automatic coloring by log level.
5View multiple container logs at once?
Yes. Open a separate log tab for each container. All tabs stream simultaneously in real time in the Services tool window.
6Open a shell inside a container from PhpStorm?
Services window → right-click container → Open Terminal. Opens an interactive shell as a tab in the integrated terminal with the correct user context.
7Docker socket not detected?
With Rancher Desktop or Podman the socket is often at a different path. Determine it with 'docker context inspect' and enter it manually under Settings → Docker.
8Share Docker configurations with the team?
Check in run configs in .idea/runConfigurations/ as XML. Connection settings are local, document the setup steps in CLAUDE.md or AGENTS.md.
9Kill processes inside a container?
Services window → Container → Processes tab. All processes with PID, CPU and memory live. Kill button sends SIGTERM or SIGKILL directly.
10Works without Docker Desktop?
Yes. PhpStorm communicates directly via socket or TCP API. Works with Rancher Desktop, Podman and remote Docker hosts without Docker Desktop.