第一步:1. 查询镜像
python@ubuntu:~/Desktop$ sudo docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 4ab4c602aa5e 2 weeks ago 1.84 kB
第二步:查询容器
python@ubuntu:~/Desktop$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6e21b4251fe3 hello-world "/hello" 56 minutes ago Exited (0) 56 minutes ago silly_nobel
第三步:3. 先删除容器
python@ubuntu:~/Desktop$ sudo docker rm 6e21b4251fe3
6e21b4251fe3
python@ubuntu:~/Desktop$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
第四步:删除镜像
python@ubuntu:~/Desktop$ sudo docker image rm hello-world
Untagged: hello-world:latest
Untagged: hello-world@sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Deleted: sha256:4ab4c602aa5eed5528a6620ff18a1dc4faef0e1ab3a5eddeddb410714478c67f
Deleted: sha256:428c97da766c4c13b19088a471de6b622b038f3ae8efa10ec5a37d6d31a2df0b
拉取镜像
python@ubuntu:~/Desktop$ sudo docker image pull library/hello-world
Using default tag: latest
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest