日期:2019-10-30 浏览次数:1347 次
1. 查询镜像
C:\Users\Administrator>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 085b8605baff 2 weeks ago 372MB
microsoft/iis latest 51ad3869d6c2 3 weeks ago 5.15GB
C:\Users\Administrator>docker rmi 085b8605baff
Error response from daemon: conflict: unable to delete 085b8605baff (must be forced) - image is being used by stopped container a1f29bf76014
不能直接删除,有容器在使用中。要先删除停止容器,再删除。
2. 查询容器
查看容器使用中
C:\Users\Administrator>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a1f29bf76014 hello-world "cmd /C 'type C:\\hel…" 16 hours ago Exited (0) 16 hours ago strange_hellman
38f71ff2e86d hello-world "cmd /C 'type C:\\hel…" 19 hours ago Exited (0) 19 hours ago zealous_mahavira
5fc9b485ca58 hello-world "cmd /C 'type C:\\hel…" 20 hours ago Exited (0) 20 hours ago upbeat_greider
b1a34a56c54c 51ad3869d6c2 "C:\\ServiceMonitor.e…" 22 hours ago Exited (0) 7 seconds ago elastic_keller
3. 先删除容器
C:\Users\Administrator>docker rm a1f29bf76014
C:\Users\Administrator>docker rm 5fc9b485ca58
C:\Users\Administrator>docker rm 38f71ff2e86d
C:\Users\Administrator>docker rm b1a34a56c54c
查看容器使用中,
C:\Users\Administrator>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
上面可以看出,容器已经删除。
4. 删除镜像
C:\Users\Administrator>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 085b8605baff 2 weeks ago 372MB
microsoft/iis latest 51ad3869d6c2 3 weeks ago 5.15GB
C:\Users\Administrator>docker rmi hello-world
C:\Users\Administrator>docker rmi microsoft/iis
C:\Users\Administrator>docker images
注意点:
1. 删除前需要保证容器是停止的 stop
2. 需要注意删除镜像和容器的命令不一样。 docker rmi ID ,其中 容器(rm) 和 镜像(rmi)
3. 顺序需要先删除容器