Home >Operation and Maintenance >Docker >How to delete a container created in docker

How to delete a container created in docker

angryTom
angryTomOriginal
2020-03-14 13:14:1159930browse

How to delete a container created in docker

How to delete containers created in docker

1. First use the docker -s -a command to list all containers

# docker ps -a
 
CONTAINER ID   IMAGE   COMMAND        CREATED        STATUS        PORTS    NAMES
f2582758af13   ubuntu  "/bin/bash"    2 hours ago    Up 2 hours             first_ubuntu
6b5b5a969241   centos  "/bin/bash"    2 days ago     Exited (0) 24 hours ago   ubuntu-web

2. Then use the docker stop command to stop the container to be deleted

docker stop <CONTAINER ID|NAME>

3. Now use the following command to delete single or multiple containers.

 docker rm <CONTAINER ID|NAME> <CONTAINER ID|NAME>

Note: You can also use the following command to delete all stopped containers at once.

docker rm $(docker ps -a -q)

For more related tutorials, please pay attention to the docker tutorial column on the PHP Chinese website.

The above is the detailed content of How to delete a container created in docker. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn