#查看版本
docker version
#查看信息
docker info
#查询某个命令的相关帮助
docker xxx --help
-a :列出本地所有的镜像(含中间映像层,默认情况下,过滤掉中间映像层);
–digests :显示镜像的摘要信息;
-f :显示满足条件的镜像;
–format :指定返回值的模板文件;
–no-trunc :显示完整的镜像信息;
-q :只显示镜像ID。
#查看本地镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 8 months ago 13.3kB
#查看所有镜像
[root@localhost ~]# docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 8 months ago 13.3kB
#查看所有镜像的id
[root@localhost ~]# docker images -aq
bf756fb1ae65
3.搜索镜像
[root@localhost ~]# docker search tomcat
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
tomcat Apache Tomcat is an open source implementati… 2827 [OK]
tomee Apache TomEE is an all-Apache Java EE certif… 83 [OK]
4.拉取镜像
#默认下载的是最新版本的镜像
[root@localhost ~]# docker pull tomcat
5.删除镜像
删除指定镜像 :docker rmi 镜像id
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat 8.5 34aaa1851899 4 days ago 530MB
tomcat latest 5f47aad0b70e 4 days ago 647MB
hello-world latest bf756fb1ae65 8 months ago 13.3kB
#可根据镜像id或名称删除,也可以在后面用空格分隔一次删除多个镜像
[root@localhost ~]# docker rmi 5f47aad0b70e
Untagged: tomcat:latest
Untagged: tomcat@sha256:c2b033c9cee06d6a3eb5a4d082935bbb8afee7478e97dcd6bc452bb6ab28da4b
Deleted: sha256:5f47aad0b70e1d6a8324543d3b7536f23baaaf09b09661dbf4e52d7b822c0157
Deleted: sha256:34ccbdf0c4b338bbe26a4c349d517fb7662b65611bd02c35f72358838aeac6b1
Deleted: sha256:5bc61859d971832370605e0fb8d1fe41e0550e3841043de1c19d971691efd4c4
Deleted: sha256:a6f52ba4967c48d8aba223ff71a9764d2dacd53490af3d1e73da96cc66f3e05b
Deleted: sha256:b0cb8e4a85df51db4e5fe10dfa149b2b3f1170c7a3a8d33b0c5ef6e104b9a980
Deleted: sha256:6a05ecc17b6c6bc8a97223bf4a04aa5ad34084270d86ca0605bf5a603e1656f4
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat 8.5 34aaa1851899 4 days ago 530MB
hello-world latest bf756fb1ae65 8 months ago 13.3kB
已生成容器的镜像无法删除,需要先删除容器,或者用 -f 强制删除
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 8 months ago 13.3kB
[root@localhost ~]# docker rmi bf756fb1ae65
Error response from daemon: conflict: unable to delete bf756fb1ae65 (must be forced) - image is being used by stopped container 764b1fdde2be
[root@localhost ~]# docker rmi -f bf756fb1ae65
Untagged: hello-world:latest
Untagged: hello-world@sha256:4cf9c47f86df71d48364001ede3a4fcd85ae80ce02ebad74156906caff5378bc
Deleted: sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
删除所有镜像
#删除所有镜像
docker rmi $(docker images -qa)