dockers镜像的制作

[root@izhp35q0sf8o31c8cz1o9tz ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              75835a67d134        3 months ago        200MB
hello-world         latest              4ab4c602aa5e        4 months ago        1.84kB
pty-fine            1.0.0               d026d81807fc        8 months ago        753MB
pty-nginx           1.0.0               1ad7f4b9e21c        8 months ago        109MB
pty                 1.0.0               6110d1d646c6        8 months ago        753MB
pty-mysql           1.0.0               58da8d1bd0d3        9 months ago        430MB
[root@izhp35q0sf8o31c8cz1o9tz ~]# mkdir /build-docker
[root@izhp35q0sf8o31c8cz1o9tz ~]# cd build-docker
-bash: cd: build-docker: No such file or directory
[root@izhp35q0sf8o31c8cz1o9tz ~]# ls
rpmbuild
[root@izhp35q0sf8o31c8cz1o9tz ~]# cd ..
[root@izhp35q0sf8o31c8cz1o9tz /]# ls
bin   build-docker  etc   lib    lost+found  mnt  proc  run   srv  tmp  var
boot  dev           home  lib64  media       opt  root  sbin  sys  usr
[root@izhp35q0sf8o31c8cz1o9tz /]# mkdir build-docker
mkdir: cannot create directory ‘build-docker’: File exists
[root@izhp35q0sf8o31c8cz1o9tz /]# cd build-docker/
[root@izhp35q0sf8o31c8cz1o9tz build-docker]# touch Dockerfile
[root@izhp35q0sf8o31c8cz1o9tz build-docker]# vim Dockerfile
[root@izhp35q0sf8o31c8cz1o9tz build-docker]# echo "/usr/sbin/httpd -DFOREGROUND" > START.SH
[root@izhp35q0sf8o31c8cz1o9tz build-docker]# chmod a+x start.sh
chmod: cannot access ‘start.sh’: No such file or directory
[root@izhp35q0sf8o31c8cz1o9tz build-docker]# echo "/usr/sbin/httpd -DFOREGROUND" > start.sh
[root@izhp35q0sf8o31c8cz1o9tz build-docker]# chmod a+x start.sh
[root@izhp35q0sf8o31c8cz1o9tz build-docker]# echo "docker image build test" > index.html
[root@izhp35q0sf8o31c8cz1o9tz build-docker]# ls
Dockerfile  index.html  start.sh  START.SH
[root@izhp35q0sf8o31c8cz1o9tz build-docker]# docker build -t 	.io/centos:httpd2 ./
Sending build context to Docker daemon   5.12kB
Step 1/5 : FROM docker.io/centos:latest
 ---> 75835a67d134
Step 2/5 : MAINTAINER <[email protected]>
 ---> Running in fe1a90de39fc
Removing intermediate container fe1a90de39fc
 ---> 6e54be4ad724
Step 3/5 : RUN yum -y install httpd
 ---> Running in e11003194715
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-88.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-88.el7.centos for package: httpd-2.4.6-88.el7.centos.x86_64
--> Processing Dependency: system-logos >= 7.92.1-1 for package: httpd-2.4.6-88.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-88.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-88.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-88.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package centos-logos.noarch 0:70.0.6-3.el7.centos will be installed
---> Package httpd-tools.x86_64 0:2.4.6-88.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch          Version                    Repository   Size
================================================================================
Installing:
 httpd               x86_64        2.4.6-88.el7.centos        base        2.7 M
Installing for dependencies:
 apr                 x86_64        1.4.8-3.el7_4.1            base        103 k
 apr-util            x86_64        1.5.2-6.el7                base         92 k
 centos-logos        noarch        70.0.6-3.el7.centos        base         21 M
 httpd-tools         x86_64        2.4.6-88.el7.centos        base         90 k
 mailcap             noarch        2.1.41-2.el7               base         31 k

Transaction Summary
================================================================================
Install  1 Package (+5 Dependent packages)

Total download size: 24 M
Installed size: 31 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/apr-util-1.5.2-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for apr-util-1.5.2-6.el7.x86_64.rpm is not installed
--------------------------------------------------------------------------------
Total                                               17 MB/s |  24 MB  00:01     
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) <[email protected]>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-5.1804.4.el7.centos.x86_64 (@Updates)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7_4.1.x86_64                                   1/6 
  Installing : apr-util-1.5.2-6.el7.x86_64                                  2/6 
  Installing : httpd-tools-2.4.6-88.el7.centos.x86_64                       3/6 
  Installing : centos-logos-70.0.6-3.el7.centos.noarch                      4/6 
  Installing : mailcap-2.1.41-2.el7.noarch                                  5/6 
  Installing : httpd-2.4.6-88.el7.centos.x86_64                             6/6 
  Verifying  : mailcap-2.1.41-2.el7.noarch                                  1/6 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                  2/6 
  Verifying  : httpd-tools-2.4.6-88.el7.centos.x86_64                       3/6 
  Verifying  : httpd-2.4.6-88.el7.centos.x86_64                             4/6 
  Verifying  : apr-1.4.8-3.el7_4.1.x86_64                                   5/6 
  Verifying  : centos-logos-70.0.6-3.el7.centos.noarch                      6/6 

Installed:
  httpd.x86_64 0:2.4.6-88.el7.centos                                            

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1                                                  
  apr-util.x86_64 0:1.5.2-6.el7                                                 
  centos-logos.noarch 0:70.0.6-3.el7.centos                                     
  httpd-tools.x86_64 0:2.4.6-88.el7.centos                                      
  mailcap.noarch 0:2.1.41-2.el7                                                 

Complete!
Removing intermediate container e11003194715
 ---> f573642a034e
Step 4/5 : ADD start.sh /usr/local/bin/start.sh
 ---> 679de9950bdb
Step 5/5 : ADD index.html /var/www/html/index.html
 ---> e2d673f33b3f
Successfully built e2d673f33b3f
Successfully tagged centos:httpd


[root@izhp35q0sf8o31c8cz1o9tz build-docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              httpd               e2d673f33b3f        4 minutes ago       302MB
centos              latest              75835a67d134        3 months ago        200MB
hello-world         latest              4ab4c602aa5e        4 months ago        1.84kB
pty-fine            1.0.0               d026d81807fc        8 months ago        753MB
pty-nginx           1.0.0               1ad7f4b9e21c        8 months ago        109MB
pty                 1.0.0               6110d1d646c6        8 months ago        753MB
pty-mysql           1.0.0               58da8d1bd0d3        9 months ago        430MB
[root@izhp35q0sf8o31c8cz1o9tz build-docker]# 


[root@izhp35q0sf8o31c8cz1o9tz build-docker]# docker save -o docker.io-centos-httpd-docker-image.tar docker.io/centos:httpd


新页签的操作:

[root@izhp35q0sf8o31c8cz1o9tz ~]# docker save -o docker.io-centos-httpd-docker-image.tar docker.io/centos:httpd
[root@izhp35q0sf8o31c8cz1o9tz ~]# ll-h
-bash: ll-h: command not found
[root@izhp35q0sf8o31c8cz1o9tz ~]# ll -h
total 298M
-rw-------. 1 root root 298M Jan 21 00:58 docker.io-centos-httpd-docker-image.tar
drwxr-xr-x. 4 root root 4.0K Oct 22 19:03 rpmbuild
[root@izhp35q0sf8o31c8cz1o9tz ~]# 





















猜你喜欢

转载自blog.csdn.net/weixin_38441551/article/details/86601146