Prerequisites

Docker is cool but can only run a container at once. In order to run a set of containers you need to use either Docker Services / docker swarm (integrated in docker) or docker-compose tool (more popular)

Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command: docker-compose up, you create and start all the services from your configuration. Use docker-compose down to shutdown services.

Install Docker

Please install Docker first.

$ sudo curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ docker-compose --version
docker-compose version 1.19.0, build 9e633ef

A 3 step process

1. Define your app’s environment

You describe the following file called docker-compose.yml

version: '3'

services:
  web:
    image: fpfis/php56-dev
    ports:
      - 9000:8080
    working_dir: /path/to/www/
    volumes:
      - web_data:/path/to/www/
    restart: always
volumes:
   web_data:

Inside you have the path to the image, the port outside:inside mapping, the volumes (pushing a directory tree inside the container )

The you run

docker-compose up

This will build and run your container

You can run multiple custom yml files e.g. web.yml and db.yml but you need to specify them:

docker-compose build -f composer/web.yml -f composer/db.yml up -d 

where option `-d is to run in background as a daemon, -f to be run the specific custom file.

The files are normal yml file to be crafted as it is suggested in docker-compose documentation

Either way you need to test the connection:

curl -v --noproxy '*' http://localhost:9000