docker stop rm rmi 命令
- 刪除鏡像的時候要確保沒有容器引用該鏡像
- 如果有容器引用的鏡像先刪除容器后刪除鏡像
- 刪除容器的時候如果正常運行請先停止容器運行

1.停止容器docker stop
Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...] Stop one or more running containers 停止一個或者多個正在運行的容器 Options: -t, --time int Seconds to wait for stop before killing it (default 10) 可添加參數-t, --time 15 等待15秒去停止容器,只寫-t默認10s
- 停止容器,可以同時一個或多個
docker stop 1fa2822325ff
docker stop -t 1fa2822325ff
docker stop -t 15 1fa2822325ff
docker stop 1fa2822325ff 00b05cfc2055
- 停止所有容器運行
docker stop $(docker ps -qa)
2.刪除容器docker rm
Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...] Remove one or more containers 刪除一個或多個容器 Options: -f, --force Force the removal of a running container (uses SIGKILL) 強制刪除一個正在運行的容器 -l, --link Remove the specified link 刪除特定的鏈接 -v, --volumes Remove anonymous volumes associated with the container 刪除與容器有關聯的匿名卷
根據容器id刪除容器,可以刪除一個或者多個
docker rm 1fa2822325ff
docker rm 1fa2822325ff 00b05cfc2055
docker rm $(docker ps -qa)
3.刪除鏡像docker rmi
Usage: docker rmi [OPTIONS] IMAGE [IMAGE...] Remove one or more images 刪除一個或多個鏡像 Options: -f, --force Force removal of the image 強制刪除鏡像 --no-prune Do not delete untagged parents 不刪除未打tagd的父鏡像
- 根據鏡像id刪除鏡像
docker rmi 0778d4c5d27e
- 根據tag刪除鏡像
docker rmi goharbor/harbor-portal:v1.9.0
- 刪除所有鏡像
docker rmi $(docker images -qa)
