Home >Operation and Maintenance >Docker >How to delete image files in docker

How to delete image files in docker

WJ
WJOriginal
2020-06-09 16:33:5114702browse

How to delete image files in docker

#How docker delete image files?

View the image id:

docker images

Note: Before deleting, please make sure there is no container using the image. If there is, if the container is running first Stop the container, delete the container, and then delete the image before deleting it.

Check the running status of the container:

docker ps //或者docker container ls

If there is a running container, stop it first

docker stop containerid

Check the running status of the container again, you can see that there are no running containers

View all containers (-a means view all)

docker ps -a //或 docker container ls -a

Delete containers

docker rm containerid

View all containers again, you can see that the container has been deleted

You can delete the image at this time

docker rmi imageid

View the image again, you can see that the image has been deleted

2. Summary

2.1. Before deleting the image, make sure that no container using the image exists. If the container exists and is running, you need to stop the container first, and then delete the container
2.2. Before deleting the container, you must use the docker rm containerid command to delete the container and the docker rmi imageid command to delete the image

Related recommendations: docker tutorial

The above is the detailed content of How to delete image files 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