How to Remove Docker Containers

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

Requirements:

I assume you have Docker installed on your computer. If you don’t have Docker installed on your computer yet, 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.

Removing Docker Containers using CONTAINER ID:

In this section, I am going to show you how to remove a Docker container using the CONTAINER ID.

First, list all the running Docker containers with the following command:

$ docker container list

NOTE: To list containers that are not running as well, use the -a option.

$ docker container list -a

As you can see, the CONTAINER ID of all the running containers are listed.

Now, let’s say, you want to remove the container with the CONTAINER ID 3f8f57988cda.

As the container is running, you have to stop it first. To do that, run the following command:

$ docker container stop 3f8f57988cda

Now, remove the container 3f8f57988cda with the following command:

$ docker container rm 3f8f57988cda

The container 3f8f57988cda should be removed.

Removing Docker Containers using Container Names:

You can also remove a Docker container using the container name.

First, list all the running containers with the following command:

$ docker container list

The container NAMES of all the running containers should be listed.

Let’s say, you want to remove the container with the name www1. As the container is running, you must stop it before you remove it.

To stop the container www1, run the following command:

$ docker container stop www1

Now, remove the container www1 with the following command:

$ docker container rm www1

The container www1 should be removed.

Force Remove Containers:

As you saw earlier, if you want to remove a container, you have to stop the container first if it’s running. Then you can remove it.

If you want to remove a container whether it’s running or not, you have to force remove that container.

To force remove a container, let’s say www2, run the following command:

$ docker container rm -f www2

You can also use the container ID instead of container name in the above example.

Removing Multiple Containers with a Single Command:

You can also remove multiple containers at the same time.

For example, let’s say, you want to remove the container www1 and www2 at the same time. To do that, run the following command:

$ docker container rm -f  www1 www2

You can use the container ID of the containers www1 and www2 in the above example as well.

So, that’s how you remove Docker containers. 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 Image vs Container

Understanding the process Docker uses to store data through images and containers will help you better design your Docker...
28/12/2020

Install Docker on Debian 9

How to Install and Use Docker on Debian 9 Stretch Docker is a containerization system like LXC for virtualizing Linux operating...
28/12/2020

Arch Linux Docker Tutorial

What Is Docker? If you read technology news websites, you’ve most likely heard about Docker and all the wonderful things...
28/12/2020
Bài Viết

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

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024