Docker compose


Start application

  • Builds, (re)creates, starts, and attaches to containers for a service.
# if the image is already present then
# this will not build the image and will run directly
docker-compose up
 
# detached mode: run containers in the background
docker-compose up -d
 
# build the image and then run
docker-compose up --build
 
# run a particular service
docker-compose up [service-name]

Stop application

# stops and deletes containers
docker-compose down

Build

  • Performs building docker image from source
  • Services are built once and then tagged, by default as project_service
  • If you change a referenced Dockerfile locally, then it will rebuild the images
  • It does not run the docker images
docker compose build
 
# build specific service
docker compose build [service-name]

Run

  • Only run the container
docker compose run [image-name]