Bart Dorsey

Docker Compose Cheatsheet

Docker recently changed from a standalone command to a plugin. You might need to run docker-compose instead of docker compose depending on which version you have.

Starting all the containers at once in the background

docker compose up -d

Shutting down all your containers

docker compose stop

Shutting down all your containers AND removing them

docker compose down

Building all your containers, ignoring docker’s cache and forcing it to rebuild everything

docker compose build --no-cache --force-rm

Looking at the status of all your containers

docker compose ps

Getting the logs for all your containers and following them

docker compose logs -f

Restarting a specific container

Use the service column from docker compose ps

docker compose restart <service>

Looking at the logs of a specific container

docker compose logs -f <service>

Starting a shell in one of your running services

<shell> will be either bash or sh or whatever shell your base image includes.

docker compose exec <service> <shell>

Running a single command inside one of your running services

This is really the same as running a shell, but you can run a single command

docker compose exec <service> <command>