Here's a cheat sheet of Docker Compose commands along with an example of each one.. If you need more details on a particular command, just type the command and --help.

 docker compose commands

 

docker-compose up


Create and start Docker containers defined in a docker-compose.yml file.

$ docker-compose up

 

docker-compose down


Stop and remove Docker containers defined in a docker-compose.yml file.

$ docker-compose down

 

docker-compose start


Start Docker containers defined in a docker-compose.yml file.

$ docker-compose start

 

docker-compose stop


Stop Docker containers defined in a docker-compose.yml file.

$ docker-compose stop

 

docker-compose restart


Restart Docker containers defined in a docker-compose.yml file.

$ docker-compose restart

 

docker-compose build


Build Docker images for services defined in a docker-compose.yml file.

$ docker-compose build

 

docker-compose pull


Pull updated Docker images for services defined in a docker-compose.yml file.

$ docker-compose pull

 

docker-compose logs


View the logs of Docker containers defined in a docker-compose.yml file.

$ docker-compose logs

 

docker-compose ps


List the status of Docker containers defined in a docker-compose.yml file.

$ docker-compose ps

 

docker-compose exec


Execute a command inside a running Docker container defined in a docker-compose.yml file.

$ docker-compose exec my_service bash

 

docker-compose run


Run a one-time command in a new container of a service defined in a docker-compose.yml file.

$ docker-compose run my_service command

 

docker-compose config


Validate and view the composed configuration file (docker-compose.yml).

$ docker-compose config

 

docker-compose top


Display the running processes of Docker containers defined in a docker-compose.yml file.

$ docker-compose top

 

docker-compose scale


Change the number of containers for a service defined in a docker-compose.yml file.

$ docker-compose up --scale my_service=3

 

docker-compose pause


Pause Docker containers defined in a docker-compose.yml file.

$ docker-compose pause

 

docker-compose unpause


Unpause Docker containers defined in a docker-compose.yml file.

$ docker-compose unpause

 

docker-compose rm


Remove stopped Docker containers defined in a docker-compose.yml file.

$ docker-compose rm

 

docker-compose kill


Forcefully stop Docker containers defined in a docker-compose.yml file.

$ docker-compose kill

 

These Docker Compose commands allow you to manage multi-container Docker applications defined in a docker-compose.yml file. By utilizing these commands, you can easily create, start, stop, and manage your Docker services as a unified application stack.