nginx mysql php5.6 php7.0 php7.1


  1. Copy .env.dist to .env:

    $ cp .env.dist .env
  2. If you plan to use the default docker repository to pull the Dockerโ€™s images, you can keep the default values of the PROJECT_NAMESPACE and REPOSITORY_NAME environment variables from the .env file and skip this step. Otherwise you need to build your own images. You can do that with:

    $ ./bin/build
  3. Start the container.

    $ docker-compose up -d
  4. Access your application via http://localhost/.



Useful docker commands

# Start containers.
$ docker-compose up -d

# Restart services.
$ docker-compose restart

# List containers.
$ docker-compose ps

# Start a terminal session for <container_name> (i.e: php).
$ docker-compose exec <container_name> /bin/bash

# View logs.
$ docker-compose logs

# List/remove network.
$ docker network [ ls | rm <network_name> ]

# List/remove volumes.
$ docker volume [ ls | rm <volume_name> ]

# Stop containers.
$ docker-compose stop

# Stop and remove containers. Any data which is not in a volume will be lost.
$ docker-compose down


Choose a different version of php

By default docker-compose.yml uses the latest tag name of the php image which corresponds to php 7.1.

    image: ${PROJECT_NAMESPACE}/${REPOSITORY_NAME}-php:latest

If you want a specific version of php, you can change it with one of those values: 5.6, 7.0 or 7.1. Example:


The default docker repository already provides the images for those php version. Otherwise you need to build them by yourself with:

$ ./bin/build

Add PHPMyAdmin

Edit docker-compose.yml and add a new service definition:

    image: phpmyadmin/phpmyadmin
     - "8080:80"
      PMA_HOST: mysql
      - backend

Then phpmyadmin will be accessible to http://localhost:8080/

Composer basic usage

Place the composer.json file that describes the dependencies of your project inside the app folder, then install the defined dependencies through the php container:

$ docker-compose run --rm php composer install

Create a new Symfony project

You can use Composer to ease the creation of a new symfony project:

$ rm -rf app/* && docker-compose run --rm -u $(id -u):$(id -g) php composer create-project symfony/framework-standard-edition .

As from Symfony3.2 you can use the environment variables into you service container configuration, using the %env(MYSQL_DATABASE)% notation:

Symfony config

Composer will create a new Symfony Standard Edition application under the app/ directory.

A minimum configuration file to get your application running under Nginx is already provided from docker-skeleton-php. Remove the default.conf file and rename symfony.conf.example into symfony.conf:

$ rm sites/default.conf
$ mv sites/symfony.conf.example sites/symfony.conf

Now remove the access check from app/web/app_dev.php:

// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !(in_array(@$_SERVER['REMOTE_ADDR'], ['', '::1']) || php_sapi_name() === 'cli-server')
) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');

Warning: After you deploy to production, make sure that you cannot access the app_dev.php

You can start the containers now:

$ docker-compose up -d

Symfony console

How can I use Symfony's console?

  • For Symfony 3:

    $ docker-compose run --rm php php bin/console
  • For Symfony 2:

    $ docker-compose run --rm php php app/console

Docker Skeleton Php

A simple Docker PHP development environment

Docker Skeleton Php Info

โญ Stars 40
๐Ÿ”— Source Code
๐Ÿ•’ Last Update a year ago
๐Ÿ•’ Created 5 years ago
๐Ÿž Open Issues 0
โž— Star-Issue Ratio Infinity
๐Ÿ˜Ž Author Federkun