When I started playing with Docker I was running a lot of commands to build image, delete containers running on old image, run containers based on new image, etc… A lot of log commands with links, volumes, etc…

Then I started searching for something to automate this task and here I get to docker-compose command, this is how you may install1 it:

Install with Pip
pip install docker-compose

And install additional bash completions2 (run as root):

Add bash completions
curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose

Then you may prepare docker-compose.yml file like:

Example compose file
web:
  build: .
  command: php -S 0.0.0.0:8000 -t /code
  ports:
    - "8000:8000"
  links:
    - db
  volumes:
    - .:/code
db:
  image: orchardup/mysql
  environment:
    MYSQL_DATABASE: wordpress

More information about syntax can be found in docs3.

And run such environment with:

Starting the Docker Compose
docker-compose up

Or to run this in background:

Starting Docker Compose permanently in the background
docker-compose up -d

To stop and cleanup it use:

Stopping Docker Compose and cleaning up
docker-compose stop && docker-compose rm -f -v

Other useful commands are:

~/2016/02/install-docker-compose/
docker-compose build --force-rm # to rebuild images and clean after
docker-compose ps               # to list containers

I’m still playing with volumes in this but don’t have anything interesting enough to paste here - maybe later.