How to Remove All Docker Containers

29/12/2020
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 must have Docker installed on your computer.

Checkout the articles below to get Docker installed on your desired Linux distribution if you don’t have Docker installed already.

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.

Removing All Running Docker Containers:

You can see a list of all the running Docker containers with the following command:

$ docker container list

As you can see, I have 4 Docker containers running.

You can of course remove these containers one by one. That’s not a problem if you have a few containers like I have in this example. But, imaging a production Docker host where you may have thousands of Docker containers running. It will be impractical to remove them one by one. Luckily, you can remove them all very easily.

NOTE: Before you proceed, make sure you don’t have any important running Docker container.

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

$ docker container rm -f $(docker container list -q)

All the running Docker containers should be removed.

As you can see, there are no more running Docker containers.

$ docker container list

Removing All Stopped Docker Containers:

On your Docker host, it’s likely that you will have a lot of stopped containers which you don’t need anymore. You can remove these unnecessary containers as well.

You can list all the stopped Docker containers on your Docker host with the following command:

$ docker container list –filter status=exited

As you can see, all the stopped Docker containers are listed.

Now, to remove all the stopped Docker containers from your Docker host, run the following command:

$ docker container rm $(docker container list –quiet –filter status=exited)

All the stopped Docker containers should be removed.

As you can see, there are no more stopped Docker container on the list.

Removing All Docker Containers:

You can also remove all the containers on your Docker host regardless of their status (running, stopped, paused etc).

You can list all the Docker containers on your Docker host regardless of their status with the following command:

$ docker container list -a

As you can see, all the containers on my Docker host whether they are running or not are listed.

Now, to remove all of these Docker containers, run the following command:

$ docker container rm -f $(docker container list -qa)

All the Docker containers on your Docker host should be removed.

So, that’s how you remove all the Docker containers from 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

Docker Compose — Memory Limits

Docker compose is a powerful utility. It saves time and reduces errors when deploying your Dockerized application. Usually,...
29/12/2020

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

A Beginner’s Guide To Docker Compose

Docker Compose is one of the most useful tools for Software Developers and System Administrators. Many jobs require someone...
29/12/2020
Bài Viết

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

Mua proxy v4 chạy socks5 để chơi game an toàn, tốc độ cao ở đâu?
18/05/2024

Thuê mua proxy Telegram trọn gói, tốc độ cao, giá siêu hời
18/05/2024

Thuê mua proxy Viettel ở đâu uy tín, chất lượng và giá tốt? 
14/05/2024

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024