第 3 章 镜像 - 021 - Docker 镜像小结

镜像小结

镜像的常用操作子命令:

  • images    显示镜像列表
  • history   显示镜像构建历史
  • commit    从容器创建新镜像
  • build     从 Dockerfile 构建镜像
  • tag       给镜像打 tag
  • pull      从 registry 下载镜像
  • push      将 镜像 上传到 registry
  • rmi       删除 Docker host 中的镜像
  • search    搜索 Docker Hub 中的镜像

 

rmi

rmi 只能删除 host 上的镜像,不会删除 registry 的镜像。

如果一个镜像对应了多个 tag,只有当最后一个 tag 被删除时,镜像才被真正删除。例如 host 中 gsophy/aaa 镜像有两个 tag:

1 root@ubuntu:~# docker images centos
2 REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
3 centos              latest              1e1148e4cc2c        5 weeks ago         202MB
4 centos              v1                  1e1148e4cc2c        5 weeks ago         202MB
5 root@ubuntu:~# 

删除其中 centos:v1 只是删除了 v1 tag,镜像本身没有删除。

1 root@ubuntu:~# docker rmi centos:v1 
2 Untagged: centos:v1
3 root@ubuntu:~# 
4 root@ubuntu:~# docker images centos
5 REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
6 centos              latest              1e1148e4cc2c        5 weeks ago         202MB

只有当 centos:latest 也被删除时,整个镜像才会被删除。

1 root@ubuntu:~# docker rmi centos:latest 
2 Untagged: centos:latest
3 Untagged: centos@sha256:38777a4106f0072649128ea4236241345a3ed21c55abbbd53bad5342549f6126
4 Deleted: sha256:1e1148e4cc2c148c6890a18e3b2d2dde41a6745ceb4e5fe94a923d811bf82ddb
5 Deleted: sha256:071d8bd765171080d01682844524be57ac9883e53079b6ac66707e192ea25956
6 root@ubuntu:~# docker images centos
7 REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
8 root@ubuntu:~#

 

search

search 让我们无需打开浏览器,在命令行中就可以搜索 Docker Hub 中的镜像。

 1 root@ubuntu:~# docker search centos
 2 NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
 3 centos                             The official build of CentOS.                   5112                [OK]                
 4 ansible/centos7-ansible            Ansible on Centos7                              119                                     [OK]
 5 jdeathe/centos-ssh                 CentOS-6 6.10 x86_64 / CentOS-7 7.5.1804 x86…   105                                     [OK]
 6 consol/centos-xfce-vnc             Centos container with "headless" VNC session…   75                                      [OK]
 7 imagine10255/centos6-lnmp-php56    centos6-lnmp-php56                              49                                      [OK]
 8 centos/mysql-57-centos7            MySQL 5.7 SQL database server                   45                                      
 9 tutum/centos                       Simple CentOS docker image with SSH access      43                                      
10 openshift/base-centos7             A Centos7 derived base image for Source-To-I…   39                                      
11 gluster/gluster-centos             Official GlusterFS Image [ CentOS-7 +  Glust…   38                                      [OK]
12 centos/postgresql-96-centos7       PostgreSQL is an advanced Object-Relational …   36                                      
13 centos/python-35-centos7           Platform for building and running Python 3.533                                      
14 kinogmt/centos-ssh                 CentOS with SSH                                 25                                      [OK]
15 openshift/jenkins-2-centos7        A Centos7 based Jenkins v2.x image for use w20                                      
16 centos/php-56-centos7              Platform for building and running PHP 5.6 ap…   18                                      
17 pivotaldata/centos-gpdb-dev        CentOS image for GPDB development. Tag names…   10                                      
18 openshift/wildfly-101-centos7      A Centos7 based WildFly v10.1 image for use …   6                                       
19 openshift/jenkins-1-centos7        DEPRECATED: A Centos7 based Jenkins v1.x ima…   4                                       
20 darksheer/centos                   Base Centos Image -- Updated hourly             3                                       [OK]
21 pivotaldata/centos                 Base centos, freshened up a little with a Do…   2                                       
22 pivotaldata/centos-mingw           Using the mingw toolchain to cross-compile t…   2                                       
23 pivotaldata/centos-gcc-toolchain   CentOS with a toolchain, but unaffiliated wi…   1                                       
24 blacklabelops/centos               CentOS Base Image! Built and Updates Daily!     1                                       [OK]
25 pivotaldata/centos7-test           CentosOS 7 image for GPDB testing               0                                       
26 pivotaldata/centos7-build          CentosOS 7 image for GPDB compilation           0                                       
27 smartentry/centos                  centos with smartentry                          0                                       [OK]
28 root@ubuntu:~#

想知道镜像都有哪些 tag,还是得访问 Docker Hub。

 

 

 

---------------------引用来自--------------------

https://mp.weixin.qq.com/s?__biz=MzIwMTM5MjUwMg==&mid=2653587632&idx=1&sn=75d558655ce7885ca531f950ca416b50&chksm=8d3080a9ba4709bfdcf507ff7be409ac23ec1f0fd6d8efdd893d7489d777b16a99f5b5d99304&scene=21#wechat_redirect

posted @ 2019-01-14 19:21  gsophy  阅读(212)  评论(0编辑  收藏  举报