Skip to content

Instantly share code, notes, and snippets.

@bartdorsey
Last active December 2, 2022 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bartdorsey/3229daee621c5078ce9a950f82b2edbc to your computer and use it in GitHub Desktop.
Save bartdorsey/3229daee621c5078ce9a950f82b2edbc to your computer and use it in GitHub Desktop.
Docker Compose Cheatsheet

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment