Docker supports a set of commands to operate on Docker Containers. It supports commands to list Containers, Remove containers etc. Below are some of the commonly used commands for Docker Containers.
List all running containers
$ docker container ls
$ docker container ls –all
Remove Docker Container
Once you know the CONTAINER ID of the containers you want to delete (using the command $ docker container ls -all), pass it to the docker container rm command
$ docker container rm e276a763ee4a
e276a763ee4a
If the container we are trying to remove is running then we will get the following error message
$ docker container rm 4f61086d2050
Error response from daemon: You cannot remove a running container 4f61086d2050bc7151461d300f92f86fd6a7aa7440cf9fdf54a953531445ffcf. Stop the container before attempting removal or force remove
In this case we should first stop the running container, before attempting to remove it
$ docker container stop 4f61086d2050
4f61086d2050
Remove all stopped containers
$ docker container prune
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Total reclaimed space: 126B
No comments:
Post a Comment