Bootstrap FreeKB - Docker - Delete a container using the docker rm command
Docker - Delete a container using the docker rm command

Updated:   |  Docker articles

This assumes you have installed Docker on Linux and Docker is running.

A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).

Before deleting a container, you'll want to use the docker ps command to determine if the container is running.

docker ps -a

CONTAINER ID     IMAGE              COMMAND                 CREATED         STATUS     PORTS     NAMES
d937372c09ab9    b939aa938add9913   "/docker-entrypoin..."  6 minutes ago   Created              foo

 

If the container is running, the docker stop command can be used to stop the container.

docker stop foo

 

The docker rm command followed by the container name will delete the container.

docker rm foo

 

Or using the container ID.

docker rm d937372c09ab9

 

Reissuing the docker ps command should now show that the container is no longer listed.

docker ps -a

CONTAINER ID     IMAGE              COMMAND                 CREATED         STATUS     PORTS     NAMES

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter a0a167 in the box below so that we can be sure you are a human.