PHP Docker

Docker stack for developing PHP applications

Development Docker PHP

PHP Docker is a fast and stable development environment that uses Docker to create a module to serve your PHP applications.

The goal of PHP Docker is to create a minimalistic development stack that is clean and uses stock modules.


  • Docker
  • Docker compose

What's Inside

  • PHP 7.1
  • Nginx
  • MariaDB
  • NodeJS

Getting Started

To get started, simply clone the repository using the command

$ git clone
$ cd php-docker

The next step is to configure the stack by modifying the .env file, the config file contains detailed comment for each configuration entry. The most important part that you need to change is the mount point.


The path that you will specify on the MOUNT will automatically be mounted as /var/www on the Docker's workspace.

Setting up Nginx

To setup Nginx, you can add vhost entries on services/nginx/sites which is automatically mounted as /etc/nginx/conf.d on Docker's workspace.

There is also a folder services/nginx/sample which contains sample vhost entries that you can refer to.

After setting up the mount points and vhosts, you can now start the stack by running

./bin/console start

Example Nginx Setup

Let's say you set your mount directory to /var/Projects and you want the following vhost entry for project /var/Projects/Web/my-site. You need to set your vhost to

server {
  server_name mysite.local;
  root /var/www/Web/my-site;
  index index.php;

  location / {
    try_files $uri /index.php$is_args$args;

  location ~ \.php {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_index index.php;
    fastcgi_pass php-fpm:9000;


PHP Docker contains a console command. The console contains preset common commands that simplify actions such starting or reloading the entire stack.


The following are the list of commands

  • start

Starts the docker stack. Will also create containers not yet created.

./bin/console start
  • stop

Fully shuts down the stack

./bin/console stop
  • restart

Restarts the stack. A restart only refreshes changes made on the mount points and the the docker compose file.

./bin/console reload
  • recreate

A reload attempts to recreate a specified container. If you made changes to a container's Dockerfile then you need to recreate that container.

./bin/console recreate php-fpm

This will attempt to recreate php-fpm container.