Docker and Docker Compose Commands
In this lesson, we'll take a look at Docker Compose!
We'll cover the following...
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.
Upon starting, docker-compose outputs all possible commands. The
most important commands for Docker Compose are:
-
docker-compose buildgenerates the Docker images for the containers with the help of theDockerfilesreferenced indocker-compose.yml. -
docker-compose pulldownloads the Docker images referenced indocker-compose.ymlfrom Docker hub. -
docker-compose up -dstarts the Docker containers in the background. Without-dthe 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--scalecan start multiple instances of a service, e.g.,docker-compose up -d --scale order=2starts two instances of the order service. The default value is one instance. -
docker-compose downstops and deletes the containers. In addition, the network and the Docker file systems, are deleted. -
docker-compose stop...