013、Dockerfile構建映象(2019-01-02 週三)

三角形發表於2019-01-03
 
Dockerfile構建映象過程分析
 
root@docker-lab:~/111# ls    #    檢視當前目錄下存在Dockerfile檔案
Dockerfile
root@docker-lab:~/111# cat Dockerfile    #    檢視Dockerfile問價內容,執行centos容器,然後安裝wget命令
FROM centos
RUN yum install -y wget
root@docker-lab:~/111# docker build -t centos-wget .    #    執行docker build 命令使用Dockerfile檔案構建映象
Sending build context to Docker daemon  2.048kB    #    傳送build context(當前目錄下所有檔案和子目錄到dokcer daemon。建議當前目錄不要存放與構建映象無關的檔案,耗時且容易失敗
Step 1/2 : FROM centos    #    開始執行centos容器
latest: Pulling from library/centos    #    從Docker Hub下載centos映象
a02a4930cb5d: Pull complete    
Digest: sha256:184e5f35598e333bfa7de10d8fb1cebb5ee4df5bc0f970bf2b1e7c7345136426
Status: Downloaded newer image for centos:latest
---> 1e1148e4cc2c    #    centos容器啟動成功,id:1e1148e4cc2c
Step 2/2 : RUN yum install -y wget    #    開始安裝wget命令
---> Running in a127bab51f51    #    執行臨時容器 a127bab51f51
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
* base: mirrors.huaweicloud.com
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.neusoft.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
Package         Arch              Version                Repository       Size
================================================================================
Installing:
wget            x86_64            1.14-18.el7            base            547 k
 
Transaction Summary
================================================================================
Install  1 Package
 
Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/wget-1.14-18.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for wget-1.14-18.el7.x86_64.rpm is not installed
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@CentOS)
From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : wget-1.14-18.el7.x86_64                                      1/1
install-info: No such file or directory for /usr/share/info/wget.info.gz
  Verifying  : wget-1.14-18.el7.x86_64                                      1/1
 
Installed:
  wget.x86_64 0:1.14-18.el7                                                     
 
Complete!
Removing intermediate container a127bab51f51    #    刪除臨時容器 a127bab51f51 
---> 8486cf558bf9
Successfully built 8486cf558bf9    #    成功構建映象 8486cf558bf9
Successfully tagged centos-wget:latest    
 
root@docker-lab:~/111# docker images    #    檢視映象列表,確認centos-wget 映象建立成功
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos-wget         latest              8486cf558bf9        59 seconds ago      272MB
centos              latest              1e1148e4cc2c        3 weeks ago         202MB
root@docker-lab:~/111# docker history centos-wget    #    檢視映象centos-wget 構建記錄,即docker的分層結構
IMAGE               CREATED              CREATED BY                                      SIZE                COMMENT
8486cf558bf9        About a minute ago   /bin/sh -c yum install -y wget                  70.7MB              
1e1148e4cc2c        3 weeks ago          /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B                  
<missing>           3 weeks ago          /bin/sh -c #(nop)  LABEL org.label-schema.sc…   0B                  
<missing>           3 weeks ago          /bin/sh -c #(nop) ADD file:6f877549795f4798a…   202MB               
 
 

相關文章