1. 程式人生 > >第 3 章 映象 - 021 - Docker 映象小結

第 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 [email protected]:~# 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 [email protected]:~#

刪除其中 centos:v1 只是刪除了 v1 tag,映象本身沒有刪除。

1 [email protected]:~# docker rmi centos:v1 
2 Untagged: centos:v1
3 [email protected]:~# 4 [email protected]:~# docker images centos 5 REPOSITORY TAG IMAGE ID CREATED SIZE 6 centos latest 1e1148e4cc2c 5 weeks ago 202MB

只有當 centos:latest 也被刪除時,整個映象才會被刪除。

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

 

search

search 讓我們無需開啟瀏覽器,在命令列中就可以搜尋 Docker Hub 中的映象。

 1 [email protected]:~# 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 [email protected]:~#

想知道映象都有哪些 tag,還是得訪問 Docker Hub。

 

 

 

---------------------引用來自--------------------

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