quangkeu95
11/18/2017 - 7:30 AM

docker-compose-cheat-sheat.md

Install Docker Compose on Linux distribution

Get the latest version of Docker Compose on Docker Compose release page

To install

curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

To uninstall sudo rm /usr/local/bin/docker-compose

Quick start Docker Compose

Getting started

Some useful command with docker-compose

Bring up services:

  • Foreground: docker-compose up
  • Background: docker-compose up -d Note: When running docker-compose in background, you may want to stop services after you have done your work by using command: docker-compose stop.

Bring down services:

docker-compose down Passing flag --volumes to remove volumes using by your containers.

Specify docker-compose file

Normally, you must be inside a docker-compose project with docker-compose.yaml file in order to user most of docker-compose command, or you can use docker-compose -f <path/to/docker-compose-file> <command> to run command on specific docker-compose project.

Define project name

Project name is used with your service name to create container name: Container Name = Project Name_Service Name_1

By default, project name is the name of the directory which contains docker-compose file.