Skip to content

Latest commit

 

History

History
222 lines (164 loc) · 5.26 KB

File metadata and controls

222 lines (164 loc) · 5.26 KB

Docker Compose

Compose is a tool for defining and running multi-container Docker applications. #docker-compose

Start compose stack

Create and start containers, networks, and volumes for your compose project. #up #boot #start

docker compose up $up_opts

Stop compose stack

Stop and remove containers, networks, images, and volumes created by up. #down #stop #halt #nuke

docker compose down $down_opts

List compose containers

List containers running in the current compose project. #ps #ls

docker compose ps

View compose logs

View output from all containers in the compose stack. #logs #tail #debug

docker compose logs -f

Build compose services

Build or rebuild services defined in the docker-compose.yml. #build #make

docker compose build

Restart compose stack

Restart all containers in the compose project. #restart #reboot

docker compose restart

Execute command in compose service

Run a one-off command in a running compose service. #exec #shell #bash

docker compose exec -it $service /bin/sh

Run a one-off command

Run a one-off command on a service. This is different from exec because it spins up a new container for the service rather than connecting to an already running one. #run #one-off

docker compose run --rm $service $command

Validate Compose config

Parse, resolve and render the compose file in canonical format. Great for debugging syntax errors or checking how environment variables are evaluated. #config #lint #check #dry-run

docker compose config

Pull compose images

Pull all images associated with your compose services. #pull #download #update

docker compose pull

Push compose images

Push all locally built images for your compose services to their respective registries. #push #upload #publish

docker compose push

List compose projects

List all running compose projects across your entire system, not just the current directory. #ls-projects #projects

docker compose ls

Remove stopped containers

Removes stopped service containers. By default, it does not remove any attached volumes. #rm #clean #purge

docker compose rm -f

Start services

Start existing containers for a service. This is useful if you previously used docker compose stop. #start #boot

docker compose start

Force kill services

Force stop service containers immediately instead of gracefully waiting. #kill #nuke #sigkill

docker compose kill

View compose processes

Display the running processes for all containers in the compose project. #top #htop #processes

docker compose top

Copy files from/to service

Copy files or folders between a service container and the local filesystem. #cp #copy #extract

docker compose cp $direction

Watch for changes

Watch build context for services and automatically rebuild/refresh containers when files are updated. Perfect for local development. #watch #dev #live-reload

docker compose watch

Scale a service

Scale a service to a specific number of replicas. #scale #replicas

docker compose up -d --scale $service=$replicas