Search⌘ K

Docker and Docker Compose Commands

Explore fundamental Docker and Docker Compose commands that help you build, start, stop, and monitor containers in microservices environments. Understand container lifecycle management, image handling, and cleanup procedures to maintain efficient microservice deployments.

Docker Compose is used for the coordination of multiple Docker containers. Microservices systems usually consist of many Docker containers. Therefore, it makes sense to start and stop the containers with Docker Compose.

Docker Compose #

Docker Compose uses the file docker-compose.yml to store information about the containers. The Docker documentation explains the structure of this file. The Docker Compose lesson contains an example of a Docker Compose file.

Upon starting, docker-compose outputs all possible commands. The most important commands for Docker Compose are:

  • docker-compose build generates the Docker images for the containers with the help of the Dockerfiles referenced in docker-compose.yml.

  • docker-compose pull downloads the Docker images referenced in docker-compose.yml from Docker hub.

  • docker-compose up -d starts the Docker containers in the background. Without -d the containers will start in the foreground so that the output of all Docker containers happens on the console. It is not particularly clear which output originates from which Docker container. The option --scale can start multiple instances of a service, e.g. docker-compose up -d --scale order=2 starts two instances of the order service. The default value is one instance.

  • docker-compose down stops ...