-
Tool for defining and running, multicontainer docker applications.
-
use yaml file to configure application services. (docker-compose.yml)
-
can start all the services with a single command, can stop all the services with a single command.
-
can scale up selected services, as and when required.
docker-compose --version
docker-compose version
Usage - TO check if docker compose is installed or not.
-
Create a file name "docker-compose.yml".
Do bash docker-compose config -d
to check the validity of the docker-compose file.
bash docker-compose up -d
Usage - Compose to create container and applications.
Note (- -d, --detach) Detached mode: Run containers in the background, print new container names. Pros - so that you have the terminal for writing other commands.
To check the running containers do - docker ps
now.
Bring down application by command.
bash docker-compose down
Usage - Will stop everything.
- How to scale some particular services.
bash docker-compose -d --scale database=4
Usage - will scale the database (i.e) redis service. This will work even if the containers are already running.