How to Stop All Docker Containers

29/12/2020
In this article, I am going to show you how to stop all Docker containers on your Docker host. So, let’s get started.

Requirements:

You must have Docker installed in order to run the commands shown in this article.

If you don’t have Docker installed, you may check the following articles on installing Docker to install Docker on your desired Linux distribution.

If you still have any problem installing Docker, you may contact me through https://support.linuxhint.com. I will be more than happy to help.

Stopping A Running Container:

You can stop any running Docker container on your Docker host. To stop a container, you need the ID or name of the container that you want to stop.

To get the container ID and name of all the running containers, run the following command:

$ docker container list

As you can see the container ID and name of all the running containers are listed.

Now, let’s say, you want to stop the container www1 or c52585c7a69b.

To do that, you may run one of the following commands:

$ docker container stop www1

Or,

$ docker container stop c52585c7a69b

The container www1 or c52585c7a69b should be stopped.

Stopping All Running Containers:

You can also stop all the running Docker containers with a single command.

To stop all the running Docker containers, run the following command:

$ docker container stop $(docker container list -q)

All the running Docker containers should be stopped.

Here, docker container list -q command returns the container ID of all the running Docker containers. Then the docker container stop command stops the containers using the container IDs.

As you can see, there is no running Docker containers in the list.

$ docker container list

Again, you can see that all the running Docker containers are stopped.

$ docker container list -a

Stopping All Docker Containers:

You can also stop any Docker containers regardless of their status (running, paused etc).

To stop all the Docker containers regardless of their status, run the following command:

$ docker container stop $(docker container list -qa)

All the Docker containers regardless of their status should be stopped.

Here, docker container list -qa command returns the container ID of all the Docker containers regardless of their status. Then the docker container stop command stops the containers using the container IDs.

You can verify whether the containers are stopped with the following command:

$ docker container list -a

As you can see, all the containers are stopped.

So, that’s how you stop all the Docker containers on your Docker host. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to Remove All Docker Containers

In this article, I am going to show you how to remove all Docker containers from your Docker host. So, let’s get started. Requirements: You...
29/12/2020

What Are Docker Image Tags, And How to Use Them?

Docker is an open platform to build, ship and run distributed applications. It simply means one can run different applications...
29/12/2020

Docker Overlay Driver and Overlay Networking

Docker comes with three networking drivers by default. Network adapters are also initialized using these drivers, carrying...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Tìm Hiểu Về Thuê Proxy US – Lợi Ích và Cách Sử Dụng Hiệu Quả
11/12/2024

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024