Public | Automated Build

Last pushed: 6 days ago
Short Description
Yet another PHP Docker image for development (based on Alpìne Linux for minimal size)
Full Description

PHP development Docker image

Yet another PHP/PHP-FPM/Jenkins Docker image for development (based on Alpine Linux for minimal size)

Bundled with:

Jenkins version is specially designed to be run as a Jenkins slave on a CI pipeline

Available tags


latest Dockerfile docker pull juliangut/phpdev
7 Dockerfile docker pull juliangut/phpdev:7
7.2 Dockerfile docker pull juliangut/phpdev:7.2
7.1 Dockerfile docker pull juliangut/phpdev:7.1
7.0 Dockerfile docker pull juliangut/phpdev:7.0
5 Dockerfile docker pull juliangut/phpdev:5
5.6 Dockerfile docker pull juliangut/phpdev:5.6


fpm Dockerfile docker pull juliangut/phpdev:fpm
7-fpm Dockerfile docker pull juliangut/phpdev:7-fpm
7.2-fpm Dockerfile docker pull juliangut/phpdev:7.2-fpm
7.1-fpm Dockerfile docker pull juliangut/phpdev:7.1-fpm
7.0-fpm Dockerfile docker pull juliangut/phpdev:7.0-fpm
5-fpm Dockerfile docker pull juliangut/phpdev:5-fpm
5.6-fpm Dockerfile docker pull juliangut/phpdev:5.6-fpm


jenkins Dockerfile docker pull juliangut/phpdev:jenkins
7-jenkins Dockerfile docker pull juliangut/phpdev:7-jenkins
7.2-jenkins Dockerfile docker pull juliangut/phpdev:7.2-jenkins
7.1-jenkins Dockerfile docker pull juliangut/phpdev:7.1-jenkins
7.0-jenkins Dockerfile docker pull juliangut/phpdev:7.0-jenkins
5-jenkins Dockerfile docker pull juliangut/phpdev:5-jenkins
5.6-jenkins Dockerfile docker pull juliangut/phpdev:5.6-jenkins

Environment variables


  • For FPM and Jenkins versions
  • Type: int
  • Default: not set
  • Recommended

In order to avoid file access problems it is recommended to set this variable to your user's UID. You can find your UID by running id -u


  • For FPM and Jenkins versions
  • Type: int
  • Default: not set
  • Recommended

In order to avoid file access problems it is recommended to set this variable to your user's GID. You can find your GID by running id -g


  • Type: int
  • Default: 0

Disable xDebug by setting a non zero value


  • Type: string
  • Default: auto discovered host's ip

Remote server (host) IP to connect to


  • Type: integer
  • Default: 9000

Remote server port to connect to, IDE should be listening on this port


  • Type: integer
  • Default: 0
  • Not recommended

Auto start remote debugging


  • Type: string
  • Default: not set
  • Not recommended

Fixed remote session identifier

Note: escape the string for use in sed


  • Type: string
  • Default: not set

Protocol format to integrate IDEs with stack trace file links. You can provide your custom format or use one of the supported formats: "phpstorm", "idea", "sublime", "textmate", "emacs" or "macvim"

Note: if you use your custom format remember to escape the string for use in "sed" command



The default working directory. You should mount your project root path in this volume.


Logging volume for PHP and PHP-FPM logs and xDebug log, profile and trace files.


Getting the image

docker pull juliangut/phpdev:latest

docker pull juliangut/phpdev:fpm-latest

Running a container

docker run -it --rm -v `pwd`:/app juliangut/phpdev:latest

docker run -d -e USER_UID=`id -u` -e USER_GID=`id -g` -v `pwd`:/app juliangut/phpdev:fpm-latest

Running built-in server

docker run -d -p 8080:8080 -v `pwd`:/app juliangut/phpdev:latest php -S -t /app/public
With Docker Compose
version: "2"

    image: juliangut/phpdev:latest
      - 8080:8080
      - .:/app
    command: "php -S -t /app/public"
docker-compose up

Access running server on "http://localhost:8080"

Running a composer command

docker run --rm -v `pwd`:/app juliangut/phpdev:latest composer [command]

Accessing a running container

docker exec -it [container_id] /bin/bash

Using xDebug

It is not recommended to have a fixed remote session identifier and an auto-started remote session using "XDEBUG_IDE_KEY" and "XDEBUG_REMOTE_AUTOSTART" environment variables respectively.

The preferred way of starting a remote debug session is by setting remote session identifier dynamically by one of the following means:

  • On browser by setting "XDEBUG_SESSION" cookie with the session identifier as its value
  • On HTTP request (cURL) by adding "XDEBUG_SESSION_START" parameter to the URI or as a POST parameter. eg: curl -X POST -F "XDEBUG_SESSION_START=PHPSTORM" http://example.local
xDebug profiler

To activate the profiler set "XDEBUG_PROFILE" cookie. Profile cachegrind.out.* files will be saved into /var/log/php directory

xDebug trace

To activate the trace set "XDEBUG_TRACE" cookie. Trace *.xt files will be saved into /var/log/php directory

Browser support

There are browser plugins/extensions to toggle these debug cookies easily

Debugging with PHPStorm

Review xDebug configuration

  • Port must be the same previously defined in XDEBUG_REMOTE_PORT environment variable
  • If you're using PHP_FPM image version remember port 9000 has already been taken by PHP-FPM itself, use 9001 or any other you please instead
Create a server

  • Server name will be used later so make it stand out
  • Host and port must be the same set in built-in server. You you can use "" to allow any host
  • Map your project root to container location (/app)
Start listening for xDebug connections

Click the phone icon to start listening for incoming connections and create a breakpoint

Start the container

Setting PHP_IDE_CONFIG environment variable to the server name you defined earlier

docker run -d -p 8080:8080 -e PHP_IDE_CONFIG="serverName=Test" -e XDEBUG_FILE_LINK_FORMAT=phpstorm -v `pwd`:/app juliangut/phpdev:latest php -S -t /app/public
Using Docker Compose
version: "2"

    image: juliangut/phpdev:latest
      - 8080:8080
      PHP_IDE_CONFIG: serverName=Test
      - .:/app
    command: "php -S -t /app/public"
docker-compose up
Firewalld & NetworkManager notice

By default firewalld blocks all outgoing connections from docker containers, such as xDebug connection to port 9000 on host. In order to allow docker containers to connect with xDebug server you need to include docker0 interface into a "trusted" zone both on NetworkManager and firewalld:

Assign docker0 interface to "trusted" zone and stop NetworkManager service

nmcli connection modify docker0 trusted
systemctl stop NetworkManager.service

Assign "trusted" zone for docker0 interface on firewalld. Additionally source is added to cover any created docker network

firewall-cmd --permanent --zone=trusted --change-interface=docker0
firewall-cmd --permanent --zone=trusted --add-source=
firewall-cmd --reload

Restart NetworkManager and reassign docker0 interface just in case

systemctl start NetworkManager.service
nmcli connection modify docker0 trusted

Restart docker service so it recreates its iptables

systemctl restart docker.service

Extending the image

The image comes with just the minimum PHP extensions, you most probably will need more.

FROM juliangut/phpdev:latest

RUN docker-php-ext-install \
    pdo_mysql \
  && pecl install \
    mongodb \
    redis \
  && docker-php-ext-enable \
    mongodb \
    redis \
  && composer global require phpunit/phpunit


See file LICENSE included with the source code for a copy of the license terms.

Docker Pull Command
Source Repository