Home > Article > Operation and Maintenance > 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!