How To Stop And Remove Containers In Docker Compose
In Docker Compose, you can stop and remove the containers that are associated with your Docker compose project file on using the docker-compose down command. Lets following the implementation stepswise.
Step 1: Create A Docker Compose Yaml File
- Firstly Created a docker-compose.yaml file with the following code.
version: '3.8'
services:
centos1:
container_name: mycontainer1
image: centos:latest
centos2:
container_name: mycontainer2
image: centos:latest
Step 2: Start The Docker Compose Containers
- Now, start the containers specified docker-compose yaml file with the following command:
docker-compose up
Step 3: Stop And Remove The Docker Compose Containers
- Finally Stop the docker containers that are associated with docker compose with the following command:
docker-compose down
Docker Stop Command |A Complete Tutorial:Defnition,Syntax,Examples
In the field of Docker container management, the docker stop command serves as a critical tool for mainly shut-down containers. This article talks about the working of the docker stop command, explaining its purpose, usage, and importance of proper container termination.