DOCKER-COMPOSE Commands Cheat Sheet

Here is a cli commands cheat sheet for DOCKER-COMPOSE command, you can use this as a quick reminder for basic commands with a brief description for each of the commands.

What is DOCKER-COMPOSE command?

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.

Compose works in all environments: production, staging, development, testing, as well as CI workflows. It also has commands for managing the whole lifecycle of your application.

# To start all containers defined in the docker-compose.yml file:
docker-compose up

# To start all containers defined in a given compose file:
docker-compose -f <path/to/compose_file.yml> up

# To start all containers in the background:
docker-compose up -d

# To rebuild the images before starting all containers:
docker-compose up --build

# To start only specific containers:
docker-compose up  

# To list all running containers:
docker-compose ps

# To stop all running containers:
docker-compose stop

# To stop and remove all containers, networks, images, and volumes:
docker-compose down --rmi all --volumes

# To follow logs output from all containers:
docker-compose logs --follow

# To follow logs output from a specific container:
docker-compose logs --follow 

# To display the environment variables used by a running container:
docker-compose run  env
    

Check out the DOCKER-COMPOSE command documentation .

You can also check our MegaSh cheatsheet tool, that has 150+ searchable linux cheat sheets in one page, so you never forget a command as you work again

Check Also

Best AI tools list