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 Compose vs Docker Swarm

Web Apps and Microservices With the container ‘revolution’ apps has grown much more than being just a database and...
29/12/2020

Installing Docker on Debian 10

In this article, I am going to show you how to install the latest Docker CE (Community Edition) on Debian 10 Buster. So,...
29/12/2020

How to Install Docker on Linux Mint

In the professional world, there are a number of a really, really powerful tools that are powering the back-end of today’s...
29/12/2020
Bài Viết

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

mua Proxy riêng ở đâu, và nó đem lại lợi ích gì cho người sử dụng
22/11/2022

Hướng dẫn sử dụng Proxy Helper Fakeip khi thuê proxy
21/11/2022

PROXY NUÔI TÀI KHOẢN FACEBOOK – KINH NGHIỆM FAKE IP – THUÊ PROXY GIÁ RẺ
14/11/2022

Mua Proxy Nuôi Zalo Giá Rẻ Tại Onet.com.vn
14/11/2022

BẢNG GIÁ MUA PROXY VIỆT NAM và PROXY US Onet.com.vn
14/11/2022