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.
- How to Install and Use Docker on Ubuntu 18.04 LTS (https://linuxhint.com/install_docker_ubuntu_1804/)
- Install Docker on Debian 9 (https://linuxhint.com/install_docker_debian_9/)
- Install Docker on CentOS 7 (https://linuxhint.com/install-docker-centos7/)
- Install Docker on Raspberry Pi (https://linuxhint.com/install_docker_raspberry_pi/)
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:
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:
All the running Docker containers should be removed.
As you can see, there are no more running Docker containers.
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:
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:
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:
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:
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.