PHP Development Docker Image
This image is aimed to help developers which need to develop and test their projects in different PHP versions
(specially free or open source software developers). It comes with the latest supported PHP versions plus the latest
The following PHP versions are available:
This container also ships with Nginx, which integrates to the right PHP-FPM version.
Start the container:
$ docker run -p 80:80 -v ~/your-app:/var/www/your-app -d "eriksencosta/php-dev:latest"
This will expose your application through port 80, which you can then access in your web browser with the address
http://localhost (or an IP address if you're using Boot2Docker).
Starting your container in this way will run your application with the latest released PHP version and will output
the Nginx access logs.
To get the real value of the image and switch between the different PHP versions, start the container in interactive
$ docker run -t -i -p 80:80 -v ~/your-app:/var/www "eriksencosta/php-dev:latest" /bin/bash
phpenv command to switch between the installed PHP versions:
# phpenv versions 5.3 5.3.29 5.4 5.4.35 5.5 5.5.19 5.6 * 5.6.3 (set by /opt/phpenv/version)
5.6, 5.5, 5.4 and 5.3 are just shortcuts.
phpenv let you define the global (system-wide) and local PHP version. To
set it globally:
# phpenv global 5.5
To set a local version, use:
# phpenv local 5.4
To install additional PHP libraries globally with Composer:
# composer global require fabpot/php-cs-fixer:dev-master
You can start the Nginx and PHP-FPM services using the helper command
# webserver start Starting PHP-FPM server. Starting Nginx server. Done.
The Zend OPCache is enabled by default. If you want to disable it, you can run the helper command
# opcache disable The Zend OPCache was disabled. You need to restart the webserver for the changes to take effect. Execute: webserver restart
Note: check the Silex Docker Example application for further usage examples.
After starting the container, access
http://localhost/info.php (or an IP address if you're using Boot2Docker).
PHP-FPM is installed for each PHP version. To start it with Nginx, use the helper command
webserver. See the Usage
Each PHP version is built with the following extensions:
- Zend OPcache
From the previous list, the following extensions were installed using PECL:
Composer is also installed. The following libraries are installed globally:
The image is built using Ansible. The playbook used is the Ansible PHP Development.
Apache License 2.0
After a log of digging, I found the reason so for anyone else with the same issue:
apt-get does not work because there is no package cache in the image, you need to run:
apt-get -qq update
Answer curtesy of: ISanych (http://stackoverflow.com/users/1169435/isanych)
Hi. Firstly, thanks for this image.
The code I'm working with relies heavily on the original 'php-mysql extension' driver for php 5.3.29.
This nginx image has the php-mysqlnd native driver installed.
I'm still new to docker. Is there a way to do this? Can I install apt-get into the image?
I get the following message after pulling: "Important: This registry version will not be supported in future versions of docker."