Docker Compose is a tool that allows developers to define and run multi-container Docker applications. It simplifies the process of managing multiple containers by providing a way to define and configure them in a single file.
With Docker Compose, developers can define the services that make up their application, including their dependencies, and then run them all together with a single command. This makes it easy to test and deploy applications in a consistent and repeatable way.
This cheat sheet provides an extensive list of Docker Compose commands and their descriptions.
Table of Contents
General Commands
Command Description docker-compose upBuilds, (re)creates, starts, and attaches to containers for a service. docker-compose downStops and removes containers, networks, images, and volumes. docker-compose buildBuilds or rebuilds services. docker-compose startStarts existing containers for a service. docker-compose stopStops running containers without removing them. docker-compose restartRestarts containers. docker-compose pausePauses running containers of a service. docker-compose unpauseUnpauses paused containers of a service. docker-compose psLists containers. docker-compose logsShows logs for a service. docker-compose execRuns a command in a running container. docker-compose runRuns a one-time command against a service.
Service Configuration
Command Description docker-compose configValidates and displays the Compose file. docker-compose versionShows the Docker Compose version. docker-compose imagesLists images used by the Compose file. docker-compose topShows the running processes of a container. docker-compose eventsStreams real-time events from containers. docker-compose killForces running containers to stop. docker-compose rmRemoves stopped containers. docker-compose pullPulls images for services. docker-compose pushPushes images for services.
Environment Variables
Command Description docker-compose config --envDisplays the environment variables used in the Compose file. docker-compose up -eSets environment variables. docker-compose up --env-fileLoads environment variables from a file.
Volumes
Command Description docker-compose volume lsLists volumes. docker-compose volume createCreates a volume. docker-compose volume rmRemoves a volume. docker-compose volume inspectDisplays detailed information about a volume.
Networking
Command Description docker-compose network lsLists networks. docker-compose network createCreates a network. docker-compose network rmRemoves a network. docker-compose network inspectDisplays detailed information about a network.
Scaling
Command Description docker-compose up --scaleScales a service to a specified number of containers. docker-compose scaleScales a service to a specified number of containers.
Deployment
Command Description docker-compose config --servicesLists services in the Compose file. docker-compose config --volumesLists volumes in the Compose file. docker-compose config --networksLists networks in the Compose file. docker-compose config --hashDisplays the hash of the Compose file. docker-compose config --quietDisplays only the hash of the Compose file.
References