A tool for Docker applications that define and run multiple containers. Set up application services using YAML files. Mainly used in the following cases.
$ docker run command gets longer
--When starting multiple containers at once
An example YAML file when the docker command is as follows.
$ docker build . $ docker run -it -v ~/Desktop/myapp:/myapp -p 3000:3000 <image> bash
The YAML file is as follows.
version: '3' services: web: build: . ports: - '3000:3000' volumes: - '.:/myapp' tty: true stdin_open: true
Web naming is arbitrary, but web or app is often used. The correspondence between docker commands (run option) and YAML files is as follows.
|docker command||YAML file|
The correspondence with the Docker command is as follows.
|docker-compose build||docker build
|docker-compose up||docker run|
|docker-compose ps||docker ps|
|docker-compose exec <sevice> <command>||docker exec <container> <command>|
|docker-compose up --build||build and run|
|docker-compose down||stop and rm|