Stop the container before attempting removal or force remove If a container is running and you try to remove it, you’ll see an error like this: :~$ docker rm container1Įrror response from daemon: You cannot remove a running container 6ef4545eef378788e5e9d7ac1cf2e0a717480608adb432be99fd9b3d3a604c12. It just displays the container id or name that your provided. You’ll not get a message like container removed in the output. You use the container ID or name in this fashion: docker rm container_id_or_name
DOCKER REMOVE CONTAINER NAME HOW TO
Now that you know how to get the container ID and name, let’s see how to remove it: Remove docker container You can also notice that the running docker containers have ‘Up’ in the Status column. The first column gives container ID and the last column gives container name. You can check all the docker containers on your system (both stopped and running) with docker ps command like this: :~$ docker ps -aĬONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESĠ7e97581c5d8 debian "bash" 9 minutes ago Up 9 minutes container2Ħef4545eef37 ubuntu "bash" 11 minutes ago Up 11 minutes container1ħ07e40ce3c5a ubuntu "/bin/bash" 15 minutes ago Exited (0) 15 minutes ago boring_payneĨ047ab8e3673 ubuntu "/bin/bash" 34 minutes ago Exited (0) 15 minutes ago relaxed_wilesĬe84231ab213 debian "bash" 42 minutes ago Exited (0) 42 minutes ago bold_golickġ2a18eaa291b hello-world "/hello" 2 days ago Exited (0) 2 days ago brave_mendeleev Practical examples of removing docker containersĪs you can guess, in order to remove a container, you need to know its name or ID.
And this is why I am going to show various scenarios in which you can delete docker containers. If you want to remove all containers, stop the running ones first and then remove them: docker ps -q | xargs docker stopīut you won’t always have a simple life with containers. In the simplest form, you can remove a docker container with the docker rm command: docker rm container_id_or_name
In this Docker beginner tutorial, I’ll show you how to remove docker containers. But containers can quickly eat disk space if you create multiple containers. Containers are awesome when it comes to testing and deploying a project.