Command to delete docker container and image

 

What is the difference between a container and an image?

https://blog.csdn.net/a1035082174/article/details/84975467

 

 

https://www.runoob.com/w3cnote/docker-clear-command.html

Docker cleanup commands

Classification programming technology

Kill all running containers

docker kill $(docker ps -a -q)

Delete all stopped containers

docker rm $(docker ps -a -q)

Delete all mirrors that are not tagged with dangling

docker rmi $(docker images -q -f dangling=true)

Delete the specified mirror by the id of the mirror

docker rmi <image id>

Delete all mirrors

docker rmi $(docker images -q)

Create aliases for these commands

# ~/.bash_aliases

# 杀死所有正在运行的容器.
alias dockerkill='docker kill $(docker ps -a -q)'

# 删除所有已经停止的容器.
alias dockercleanc='docker rm $(docker ps -a -q)'

# 删除所有未打标签的镜像.
alias dockercleani='docker rmi $(docker images -q -f dangling=true)'

# 删除所有已经停止的容器和未打标签的镜像.
alias dockerclean='dockercleanc || true && dockercleani'

 

 

 

https://blog.csdn.net/qq_26709459/article/details/80785761

Docker deletes images and containers

SuperButton 2018-06-23 18:28:58 103898 Collection 89

Category column: environment build Docker article tags: docker delete image container

copyright

To delete the image in docker, we can use the followingCommand :

docker rmi 镜像id

To delete a container in docker, you can use the following command :

docker rm 容器id

Use the following command to view the currently running container

docker ps

For the exited container, you can use the following command to view:

docker ps -a

For example:
View the currently running containers:
Write picture description here
View all images:
Write picture description here
View all quitted containers:
Write picture description here
Download the image we want to delete "button-api":
Write picture description here
At this time, it is found that the deletion fails. According to the prompt information, you can know that the image we want to delete is currently It is used by the container whose id is "a4516aee2e7a", so we must delete the stopped container before deleting the image.
Write picture description here
Delete the "button-api" image again after deleting the container:
Write picture description here
Now it is found that the deletion is successful.

Re-query all mirrors and find that "button-api" has been deleted:
Write picture description here

When deleting, you may also encounter the following situations. If multiple mirror IDs are the same, the deletion will also be unsuccessful:
Write picture description here
At this time, we can also delete according to "REPOSITORY" and "TAR":
Write picture description here

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I now know the difference between deleting a container and deleting an image.

 

 

And restart the container that was started before, so this is the case, so you restart the container of the XTDrone that you modified before, instead of running the following command again, it will create a new container for you. Note that it was started before restarting. Use the command in the picture below for the container.

sudo docker run -p 6080:80 -p 5900:5900 -e RESOLUTION=1920x1080 -v /dev/shm:/dev/shm xtdrone-melodic

https://blog.csdn.net/weixin_33943836/article/details/85977604?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&dist_request_id=1328741.14462.16168415469253443&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

 

Then the ID of the simulation docker image container of Prometheus based on XTDrone docker I am getting this time is c08ef8110bd9

Next time I restart the computer and then start this container command I think it should be docker run c08ef8110bd9

Guess you like

Origin blog.csdn.net/sinat_16643223/article/details/115263050