Docker定制容器镜像的2种方法(推荐)

2020-06-17 06:44:43易采站长站整理

Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-2.1511.el7.centos.2.10.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 : fipscheck-1.4.1-5.el7.x86_64 1/6
Installing : fipscheck-lib-1.4.1-5.el7.x86_64 2/6
Installing : openssh-6.6.1p1-25.el7_2.x86_64 3/6
Installing : tcp_wrappers-libs-7.6-77.el7.x86_64 4/6
Installing : openssh-server-6.6.1p1-25.el7_2.x86_64 5/6
Installing : net-tools-2.0-0.17.20131004git.el7.x86_64 6/6
Verifying : openssh-6.6.1p1-25.el7_2.x86_64 1/6
Verifying : openssh-server-6.6.1p1-25.el7_2.x86_64 2/6
Verifying : net-tools-2.0-0.17.20131004git.el7.x86_64 3/6
Verifying : tcp_wrappers-libs-7.6-77.el7.x86_64 4/6
Verifying : fipscheck-lib-1.4.1-5.el7.x86_64 5/6
Verifying : fipscheck-1.4.1-5.el7.x86_64 6/6

Installed:
net-tools.x86_64 0:2.0-0.17.20131004git.el7
openssh-server.x86_64 0:6.6.1p1-25.el7_2

Dependency Installed:
fipscheck.x86_64 0:1.4.1-5.el7 fipscheck-lib.x86_64 0:1.4.1-5.el7
openssh.x86_64 0:6.6.1p1-25.el7_2 tcp_wrappers-libs.x86_64 0:7.6-77.el7

Complete!
---> 7b249ed8cb54
Removing intermediate container 5626d8f0f892
Step 4 : RUN mkdir /var/run/sshd
---> Running in fc94a139d438
---> ea2826eccc91
Removing intermediate container fc94a139d438
Step 5 : RUN echo 'root:iloveworld' | chpasswd
---> Running in ba53283081a7
---> 7ce1ddb5d9c0
Removing intermediate container ba53283081a7
Step 6 : RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
---> Running in 4112281a5bf0
---> be21fb6b5b1e
Removing intermediate container 4112281a5bf0
Step 7 : ENV HISTTIMEFORMAT "%F %T "
---> Running in f2081726e403
---> f3fafca42170
Removing intermediate container f2081726e403
Step 8 : RUN ssh-keygen -A
---> Running in 2ca9e743dee7
ssh-keygen: generating new host keys: RSA1 RSA DSA ECDSA ED25519
---> 1a927943bee7
Removing intermediate container 2ca9e743dee7
Step 9 : RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
---> Running in afd43cc6d4d6
---> 4a0cacf6cd72
Removing intermediate container afd43cc6d4d6
Step 10 : EXPOSE 22
---> Running in a03551bc3bcb
---> 3af544106bf4
Removing intermediate container a03551bc3bcb
Step 11 : CMD /usr/sbin/sshd -D
---> Running in f45fe5eb5561
---> d4620c9949b8
Removing intermediate container f45fe5eb5561
Successfully built d4620c9949b8

3.查看镜像列表,并创建容器