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

How to delete image files in docker

WJ
Release: 2020-06-09 16:33:51
Original
14694 people have browsed it

How to delete image files in docker

#How docker delete image files?

View the image id:

docker images
Copy after login

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
Copy after login

If there is a running container, stop it first

docker stop containerid
Copy after login

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
Copy after login

Delete containers

docker rm containerid
Copy after login

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

You can delete the image at this time

docker rmi imageid
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template