Member-only story
Docker compose Commands
Docker Compose is a tool used for defining and running multi-container Docker applications. It uses YAML files to configure the services, networks, and volumes for your application’s containers. Here are some commonly used Docker Compose commands:
👉 docker-compose up: This command creates and starts all the containers defined in your docker-compose.yml
file. If the containers don't exist, they are created.
$ docker-compose up
If you want the containers to run in detached mode (in the background), you can use the -d
flag:
$ docker-compose up -d
👉 docker-compose down: This command stops and removes all the containers defined in your docker-compose.yml
file.
$ docker-compose down
👉 docker-compose ps: This command shows the status of containers managed by Docker Compose.
$ docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
example-foo-1 alpine "/entrypoint.â¦" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
By default, only running containers are shown. --all
flag can be used to include stopped containers.
$ docker compose ps --all
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
example-foo-1 alpine "/entrypoint.â¦" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
example-bar-1 alpine…