3. docker-compose

最後更新: 2019-08-26



Compose is a tool for defining and running multi-container Docker applications

YAML file to configure your application





-v, --version

-f, --file FILE             Specify an alternate compose file (default: docker-compose.yml)

-p, --project-name NAME     Specify an alternate project name (default: directory name)



  build              Build or rebuild services
  bundle             Generate a Docker bundle from the Compose file
  config             Validate and view the Compose file
  create             Create services
  down               Stop and remove containers, networks, images, and volumes   
  events             Receive real time events from containers
  exec               Execute a command in a running container
  help               Get help on a command
  images             List images
  kill               Kill containers
  logs               View output from containers
  pause              Pause services
  port               Print the public port for a port binding
  ps                 List containers
  pull               Pull service images
  push               Push service images
  restart            Restart services
  rm                 Remove stopped containers
  run                Run a one-off command
  scale              Set number of containers for a service
  start              Start services
  stop               Stop services
  top                Display the running processes
  unpause            Unpause services
  up                 Create and start containers
  version            Show the Docker-Compose version information


Start/Stop with docker reverse proxy


* Start

docker-compose -f proxy.yml up -d

-d, --detach               Detached mode: Run containers in the background, print new container names.

* Stop

docker-compose -f proxy.yml stop

Stops running containers without removing them. They can be started again with docker-compose start.

* up

Builds, (re)creates, starts, and attaches to containers for a service.

* down

Stops containers and removes containers, networks, volumes, and images created by up.

Networks and volumes defined as external are never removed.