This tutorial will show you how to stop Docker containers using several different methods.
Basic Syntax
The basic syntax to stop the Docker container is shown below:
Or
Using the above syntax, you can stop one or more containers easily with a single command.
Stopping a Single Container
Before stopping any container, you will first need to find the ID or name of the Docker containers running on your system.
You can list all the Docker containers running on your system with the following command:
After entering the above command, you should get the following output:
9392aab37f99 wordpress "docker-entrypoint.s…" About an hour ago Up
About an hour 0.0.0.0:8081->80/tcp wpcontainer
bcbc64840b0a mariadb "docker-entrypoint.s…" About an hour ago
Up About an hour 3306/tcp wordpressdb
3e5cddafb61d technosoft2000/calibre-web:v1.1.9 "/bin/bash -c /init/…"
20 hours ago Up About a minute 0.0.0.0:8082->8083/tcp calibre-web
Now, you will have have a list of all the Docker containers currently running, including the name and ID of every container.
Next, stop the Docker container named calibre-web or ID 3e5cddafb61d by running the following command:
Or
You can also use the “kill” parameter instead of “stop” to stop the running Docker container, as shown below:
Or
Next, to verify the status of the calibre-web container, enter the following command:
After entering the above command, you should get the below output:
-c /init/…" 20 hours ago Exited (137) 33 seconds ago calibre-web
Stop Multiple Container
It is also possible to stop multiple containers using a single command.
For example, to stop the containers named “wpcontainer” and “wordpressdb,” run the following command:
Stopping All Running Containers
You can also stop all running containers using the “docker container ls -aq” option with the “docker container stop” command.
Run the following command to generate a list of all running containers and stop them.
Verify all stopped containers with the following command:
After entering the above command, you should get the following output:
592b9fe9f478 drupal "docker-php-entrypoi…" 2 hours ago Exited (0)
25 seconds ago mystifying_cartwright
9392aab37f99 wordpress "docker-entrypoint.s…" 2 hours ago Exited (128)
17 minutes ago 0.0.0.0:8081->80/tcp wpcontainer
bcbc64840b0a mariadb "docker-entrypoint.s…" 2 hours ago Exited (0)
25 seconds ago wordpressdb
3e5cddafb61d technosoft2000/calibre-web:v1.1.9 "/bin/bash -c /init/…"
21 hours ago Exited (137) 16 seconds ago calibre-web
Conclusion
In the guide provided by this article, you learned how to stop running Docker containers using several different methods. You can use whichever method works best for you to stop Docker containers from running.
from Linux Hint https://ift.tt/31u6w9k
0 Comments