赞
踩
Docker是一种容器,准确来说是一个应用容器引擎,比如一个centos服务器系统,当前的生产环境是jdk8,mysql5.1,nginx5,那么我们可以通过Docker把当前系统‘拷贝’,然后‘粘贴’在centos服务器上通过简单的操作就能部署完全相同的环境。
而这之间的’拷贝‘和’粘贴‘,就需要Dokcer这种容器来实现。
比如说,程序员A和程序员B分别要在不同的服务器上部署同一个项目。
但是程序员A的服务器是jdk8,mysql5.1,程序员B的服务器是jdk9,mysql5.5
那么当程序员A把项目文件发给程序员B,程序员B部署时却出现了错误,原因就是服务器环境差异所造成的一种bug等等,比如数据库版本不匹配啊,jdk版本不匹配啊等等。
同样的案例数不胜数,相信大家也都遇到过,一个项目在朋友的电脑上能跑起来,在自己的电脑上却跑不起来,原因又找不到的问题。
所以这个时候呢,就需要docker这个东西来把程序员A的服务器环境在docker容器里头实现,然后再把它拿到程序员b所在的服务器进行部署,使两个程序员的服务器环境完全一致,就可以解决这个问题了。
服务器环境
Docker可以运行在Windows,Mac,CentOS,Ubuntu操作系统上,这里我的演示是基于CentOS系统的VPS服务器来演示。
服务器性质:vps 新加坡节点 OpenVZ架构
服务器运营商:https://my.webhorizon.in/
服务器版本:CentOS-7-x86_64-minimal
Docker版本:17.03 CE社区版
执行安装命令
1、yum 包更新到最新
yum update
Dependency Installed: bc.x86_64 0:1.06.95-13.el7 elfutils-default-yama-scope.noarch 0:0.176-5.el7 json-c.x86_64 0:0.11-4.el7_0 libsmartcols.x86_64 0:2.23.2-65.el7_9.1 lz4.x86_64 0:1.8.3-1.el7 nss-pem.x86_64 0:1.0.3-7.el7 Updated: acl.x86_64 0:2.2.51-15.el7 audit-libs.x86_64 0:2.8.5-4.el7 bash.x86_64 0:4.2.46-34.el7 binutils.x86_64 0:2.27-44.base.el7 ca-certificates.noarch 0:2020.2.41-70.0.el7_8 centos-release.x86_64 0:7-9.2009.1.el7.centos chkconfig.x86_64 0:1.7.6-1.el7 coreutils.x86_64 0:8.22-24.el7_9.2 cpio.x86_64 0:2.11-28.el7 cryptsetup-libs.x86_64 0:2.0.3-6.el7 curl.x86_64 0:7.29.0-59.el7_9.1 cyrus-sasl-lib.x86_64 0:2.1.26-23.el7 dbus.x86_64 1:1.10.24-15.el7 dbus-libs.x86_64 1:1.10.24-15.el7 device-mapper.x86_64 7:1.02.170-6.el7_9.5 device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 diffutils.x86_64 0:3.3-5.el7 dracut.x86_64 0:033-572.el7 e2fsprogs-libs.x86_64 0:1.42.9-19.el7 elfutils-libelf.x86_64 0:0.176-5.el7 elfutils-libs.x86_64 0:0.176-5.el7 expat.x86_64 0:2.1.0-12.el7 file-libs.x86_64 0:5.11-37.el7 filesystem.x86_64 0:3.2-25.el7 findutils.x86_64 1:4.5.11-6.el7 fipscheck.x86_64 0:1.4.1-6.el7 fipscheck-lib.x86_64 0:1.4.1-6.el7 gawk.x86_64 0:4.0.2-4.el7_3.1 glib2.x86_64 0:2.56.1-9.el7_9 glibc.x86_64 0:2.17-324.el7_9 glibc-common.x86_64 0:2.17-324.el7_9 gmp.x86_64 1:6.0.0-15.el7 gnupg2.x86_64 0:2.0.22-5.el7_5 grep.x86_64 0:2.20-3.el7 gzip.x86_64 0:1.5-10.el7 hostname.x86_64 0:3.13-3.el7_7.1 info.x86_64 0:5.1-5.el7 initscripts.x86_64 0:9.49.53-1.el7_9.1 iproute.x86_64 0:4.11.0-30.el7 iptables.x86_64 0:1.4.21-35.el7 iputils.x86_64 0:20160308-10.el7 kmod.x86_64 0:20-28.el7 kmod-libs.x86_64 0:20-28.el7 kpartx.x86_64 0:0.4.9-134.el7_9 krb5-libs.x86_64 0:1.15.1-50.el7 libacl.x86_64 0:2.2.51-15.el7 libattr.x86_64 0:2.4.46-13.el7 libblkid.x86_64 0:2.23.2-65.el7_9.1 libcap.x86_64 0:2.22-11.el7 libcom_err.x86_64 0:1.42.9-19.el7 libcurl.x86_64 0:7.29.0-59.el7_9.1 libdb.x86_64 0:5.3.21-25.el7 libdb-utils.x86_64 0:5.3.21-25.el7 libffi.x86_64 0:3.0.13-19.el7 libgcc.x86_64 0:4.8.5-44.el7 libgcrypt.x86_64 0:1.5.3-14.el7 libmount.x86_64 0:2.23.2-65.el7_9.1 libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3 libpwquality.x86_64 0:1.2.3-5.el7 libselinux.x86_64 0:2.5-15.el7 libsemanage.x86_64 0:2.5-14.el7 libsepol.x86_64 0:2.5-10.el7 libssh2.x86_64 0:1.8.0-4.el7 libstdc++.x86_64 0:4.8.5-44.el7 libtasn1.x86_64 0:4.10-1.el7 libtirpc.x86_64 0:0.2.4-0.16.el7 libuser.x86_64 0:0.60-9.el7 libuuid.x86_64 0:2.23.2-65.el7_9.1 libxml2.x86_64 0:2.9.1-6.el7.5 lm_sensors-libs.x86_64 0:3.4.0-8.20160601gitf9185e5.el7 lua.x86_64 0:5.1.4-15.el7 mariadb-libs.x86_64 1:5.5.68-1.el7 ncurses.x86_64 0:5.9-14.20130511.el7_4 ncurses-base.noarch 0:5.9-14.20130511.el7_4 ncurses-libs.x86_64 0:5.9-14.20130511.el7_4 net-snmp.x86_64 1:5.7.2-49.el7_9.1 net-snmp-agent-libs.x86_64 1:5.7.2-49.el7_9.1 net-snmp-libs.x86_64 1:5.7.2-49.el7_9.1 net-snmp-utils.x86_64 1:5.7.2-49.el7_9.1 nspr.x86_64 0:4.25.0-2.el7_9 nss.x86_64 0:3.53.1-7.el7_9 nss-softokn.x86_64 0:3.53.1-6.el7_9 nss-softokn-freebl.x86_64 0:3.53.1-6.el7_9 nss-sysinit.x86_64 0:3.53.1-7.el7_9 nss-tools.x86_64 0:3.53.1-7.el7_9 nss-util.x86_64 0:3.53.1-1.el7_9 openldap.x86_64 0:2.4.44-23.el7_9 openssh.x86_64 0:7.4p1-21.el7 openssh-clients.x86_64 0:7.4p1-21.el7 openssh-server.x86_64 0:7.4p1-21.el7 openssl-libs.x86_64 1:1.0.2k-21.el7_9 p11-kit.x86_64 0:0.23.5-3.el7 p11-kit-trust.x86_64 0:0.23.5-3.el7 pam.x86_64 0:1.1.8-23.el7 passwd.x86_64 0:0.79-6.el7 pcre.x86_64 0:8.32-17.el7 perl.x86_64 4:5.16.3-299.el7_9 perl-Getopt-Long.noarch 0:2.40-3.el7 perl-Pod-Escapes.noarch 1:1.04-299.el7_9 perl-Socket.x86_64 0:2.010-5.el7 perl-libs.x86_64 4:5.16.3-299.el7_9 perl-macros.x86_64 4:5.16.3-299.el7_9 pinentry.x86_64 0:0.8.1-17.el7 procps-ng.x86_64 0:3.3.10-28.el7 psmisc.x86_64 0:22.20-17.el7 python.x86_64 0:2.7.5-90.el7 python-libs.x86_64 0:2.7.5-90.el7 python-pycurl.x86_64 0:7.19.0-19.el7 python-urlgrabber.noarch 0:3.10-10.el7 quota.x86_64 1:4.01-19.el7 quota-nls.noarch 1:4.01-19.el7 readline.x86_64 0:6.2-11.el7 rpcbind.x86_64 0:0.2.0-49.el7 rpm.x86_64 0:4.11.3-45.el7 rpm-build-libs.x86_64 0:4.11.3-45.el7 rpm-libs.x86_64 0:4.11.3-45.el7 rpm-python.x86_64 0:4.11.3-45.el7 sed.x86_64 0:4.2.2-7.el7 setup.noarch 0:2.8.71-11.el7 shadow-utils.x86_64 2:4.6-5.el7 shared-mime-info.x86_64 0:1.8-5.el7 sqlite.x86_64 0:3.7.17-8.el7_7.1 systemd.x86_64 0:219-78.el7_9.3 systemd-libs.x86_64 0:219-78.el7_9.3 systemd-sysv.x86_64 0:219-78.el7_9.3 tar.x86_64 2:1.26-35.el7 tmpwatch.x86_64 0:2.11-6.el7 tzdata.noarch 0:2021a-1.el7 util-linux.x86_64 0:2.23.2-65.el7_9.1 vim-minimal.x86_64 2:7.4.629-8.el7_9 wget.x86_64 0:1.14-18.el7_6.1 xz.x86_64 0:5.2.2-1.el7 xz-libs.x86_64 0:5.2.2-1.el7 yum.noarch 0:3.4.3-168.el7.centos yum-plugin-fastestmirror.noarch 0:1.1.31-54.el7_8 zlib.x86_64 0:1.2.7-19.el7_9 Complete!
2、安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
yum install -y yum-utils device-mapper-persistent-data lvm2
[root@abc906093117 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.aktkn.sg * extras: mirror.aktkn.sg * updates: mirror.aktkn.sg Resolving Dependencies --> Running transaction check ---> Package device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 will be installed --> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 --> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 --> Processing Dependency: libaio.so.1()(64bit) for package: device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 ---> Package lvm2.x86_64 7:2.02.187-6.el7_9.5 will be installed --> Processing Dependency: lvm2-libs = 7:2.02.187-6.el7_9.5 for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64 --> Processing Dependency: liblvm2app.so.2.2(Base)(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64 --> Processing Dependency: libdevmapper-event.so.1.02(Base)(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64 --> Processing Dependency: liblvm2app.so.2.2()(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64 --> Processing Dependency: libdevmapper-event.so.1.02()(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64 ---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed --> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch --> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-54.el7_8.noarch --> Running transaction check ---> Package device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 will be installed ---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed ---> Package libxml2-python.x86_64 0:2.9.1-6.el7.5 will be installed ---> Package lvm2-libs.x86_64 7:2.02.187-6.el7_9.5 will be installed --> Processing Dependency: device-mapper-event = 7:1.02.170-6.el7_9.5 for package: 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 ---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed --> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch --> Running transaction check ---> Package device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 will be installed ---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================ Package Arch Version Repository Size ============================================================================================================ Installing: device-mapper-persistent-data x86_64 0.8.5-3.el7_9.2 updates 423 k lvm2 x86_64 7:2.02.187-6.el7_9.5 updates 1.3 M yum-utils noarch 1.1.31-54.el7_8 base 122 k Installing for dependencies: device-mapper-event x86_64 7:1.02.170-6.el7_9.5 updates 192 k device-mapper-event-libs x86_64 7:1.02.170-6.el7_9.5 updates 192 k libaio x86_64 0.3.109-13.el7 base 24 k libxml2-python x86_64 2.9.1-6.el7.5 base 247 k lvm2-libs x86_64 7:2.02.187-6.el7_9.5 updates 1.1 M python-chardet noarch 2.2.1-3.el7 base 227 k python-kitchen noarch 1.1.1-5.el7 base 267 k Transaction Summary ============================================================================================================ Install 3 Packages (+7 Dependent packages) Total download size: 4.1 M Installed size: 12 M Downloading packages: (1/10): device-mapper-event-1.02.170-6.el7_9.5.x86_64.rpm | 192 kB 00:00:00 (2/10): lvm2-2.02.187-6.el7_9.5.x86_64.rpm | 1.3 MB 00:00:00 (3/10): lvm2-libs-2.02.187-6.el7_9.5.x86_64.rpm | 1.1 MB 00:00:00 (4/10): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:00 (5/10): device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64.rpm | 192 kB 00:00:00 (6/10): device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64.rpm | 423 kB 00:00:00 (7/10): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00 (8/10): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00 (9/10): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00 (10/10): libxml2-python-2.9.1-6.el7.5.x86_64.rpm | 247 kB 00:00:00 ------------------------------------------------------------------------------------------------------------ Total 11 MB/s | 4.1 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64 1/10 Installing : libaio-0.3.109-13.el7.x86_64 2/10 Installing : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 3/10 Installing : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 4/10 Installing : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 5/10 Installing : libxml2-python-2.9.1-6.el7.5.x86_64 6/10 Installing : python-chardet-2.2.1-3.el7.noarch 7/10 Installing : python-kitchen-1.1.1-5.el7.noarch 8/10 Installing : yum-utils-1.1.31-54.el7_8.noarch 9/10 Installing : 7:lvm2-2.02.187-6.el7_9.5.x86_64 10/10 Verifying : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 1/10 Verifying : 7:lvm2-2.02.187-6.el7_9.5.x86_64 2/10 Verifying : python-chardet-2.2.1-3.el7.noarch 3/10 Verifying : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 4/10 Verifying : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 5/10 Verifying : libxml2-python-2.9.1-6.el7.5.x86_64 6/10 Verifying : python-kitchen-1.1.1-5.el7.noarch 7/10 Verifying : libaio-0.3.109-13.el7.x86_64 8/10 Verifying : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64 9/10 Verifying : yum-utils-1.1.31-54.el7_8.noarch 10/10 Installed: device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 lvm2.x86_64 7:2.02.187-6.el7_9.5 yum-utils.noarch 0:1.1.31-54.el7_8 Dependency Installed: device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 libaio.x86_64 0:0.3.109-13.el7 libxml2-python.x86_64 0:2.9.1-6.el7.5 lvm2-libs.x86_64 7:2.02.187-6.el7_9.5 python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7 Complete!
3、 设置yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@abc906093117 ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repoLoaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
4、 安装docker,出现输入的界面都按 y
yum install -y docker-ce
[root@abc906093117 ~]# yum install -y docker-ce Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.aktkn.sg * extras: mirror.aktkn.sg * updates: mirror.aktkn.sg docker-ce-stable | 3.5 kB 00:00:00 (1/2): docker-ce-stable/7/x86_64/primary_db | 62 kB 00:00:00 (2/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00 Resolving Dependencies --> Running transaction check ---> Package docker-ce.x86_64 3:20.10.7-3.el7 will be installed --> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-20.10.7-3.el7.x86_64 --> Processing Dependency: containerd.io >= 1.4.1 for package: 3:docker-ce-20.10.7-3.el7.x86_64 --> Processing Dependency: libseccomp >= 2.3 for package: 3:docker-ce-20.10.7-3.el7.x86_64 --> Processing Dependency: docker-ce-cli for package: 3:docker-ce-20.10.7-3.el7.x86_64 --> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.7-3.el7.x86_64 --> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.7-3.el7.x86_64 --> Running transaction check ---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed --> Processing Dependency: selinux-policy-targeted >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch --> Processing Dependency: selinux-policy-base >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch --> Processing Dependency: selinux-policy >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch --> Processing Dependency: policycoreutils >= 2.5-11 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch --> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch --> Processing Dependency: libselinux-utils for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch ---> Package containerd.io.x86_64 0:1.4.6-3.1.el7 will be installed ---> Package docker-ce-cli.x86_64 1:20.10.7-3.el7 will be installed --> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.7-3.el7.x86_64 ---> Package docker-ce-rootless-extras.x86_64 0:20.10.7-3.el7 will be installed --> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64 --> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64 ---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed ---> Package libseccomp.x86_64 0:2.3.1-4.el7 will be installed --> Running transaction check ---> Package docker-scan-plugin.x86_64 0:0.8.0-3.el7 will be installed ---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed --> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64 --> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64 --> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64 ---> Package libselinux-utils.x86_64 0:2.5-15.el7 will be installed ---> Package policycoreutils.x86_64 0:2.5-34.el7 will be installed ---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed --> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64 --> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64 --> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64 --> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64 --> Processing Dependency: libselinux-python for package: policycoreutils-python-2.5-34.el7.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64 --> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64 --> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64 --> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64 --> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64 ---> Package selinux-policy.noarch 0:3.13.1-268.el7_9.2 will be installed ---> Package selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2 will be installed ---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed --> Running transaction check ---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed ---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed ---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed ---> Package libselinux-python.x86_64 0:2.5-15.el7 will be installed ---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed ---> Package python-IPy.noarch 0:0.75-6.el7 will be installed ---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================ Package Arch Version Repository Size ============================================================================================================ Installing: docker-ce x86_64 3:20.10.7-3.el7 docker-ce-stable 27 M Installing for dependencies: audit-libs-python x86_64 2.8.5-4.el7 base 76 k checkpolicy x86_64 2.5-8.el7 base 295 k container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k containerd.io x86_64 1.4.6-3.1.el7 docker-ce-stable 34 M docker-ce-cli x86_64 1:20.10.7-3.el7 docker-ce-stable 33 M docker-ce-rootless-extras x86_64 20.10.7-3.el7 docker-ce-stable 9.2 M docker-scan-plugin x86_64 0.8.0-3.el7 docker-ce-stable 4.2 M fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k fuse3-libs x86_64 3.6.1-4.el7 extras 82 k libcgroup x86_64 0.41-21.el7 base 66 k libseccomp x86_64 2.3.1-4.el7 base 56 k libselinux-python x86_64 2.5-15.el7 base 236 k libselinux-utils x86_64 2.5-15.el7 base 151 k libsemanage-python x86_64 2.5-14.el7 base 113 k policycoreutils x86_64 2.5-34.el7 base 917 k policycoreutils-python x86_64 2.5-34.el7 base 457 k python-IPy noarch 0.75-6.el7 base 32 k selinux-policy noarch 3.13.1-268.el7_9.2 updates 498 k selinux-policy-targeted noarch 3.13.1-268.el7_9.2 updates 7.0 M setools-libs x86_64 3.3.8-4.el7 base 620 k slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k Transaction Summary ============================================================================================================ Install 1 Package (+21 Dependent packages) Total download size: 117 M Installed size: 469 M Downloading packages: (1/22): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00 (2/22): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00 (3/22): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00 warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.7-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY Public key for docker-ce-20.10.7-3.el7.x86_64.rpm is not installed (4/22): docker-ce-20.10.7-3.el7.x86_64.rpm | 27 MB 00:00:01 (5/22): containerd.io-1.4.6-3.1.el7.x86_64.rpm | 34 MB 00:00:01 (6/22): docker-ce-rootless-extras-20.10.7-3.el7.x86_64.rpm | 9.2 MB 00:00:00 (7/22): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00 (8/22): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00 (9/22): libselinux-python-2.5-15.el7.x86_64.rpm | 236 kB 00:00:00 (10/22): libselinux-utils-2.5-15.el7.x86_64.rpm | 151 kB 00:00:00 (11/22): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00 (12/22): docker-scan-plugin-0.8.0-3.el7.x86_64.rpm | 4.2 MB 00:00:00 (13/22): policycoreutils-2.5-34.el7.x86_64.rpm | 917 kB 00:00:00 (14/22): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00 (15/22): docker-ce-cli-20.10.7-3.el7.x86_64.rpm | 33 MB 00:00:01 (16/22): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00 (17/22): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00 (18/22): libseccomp-2.3.1-4.el7.x86_64.rpm | 56 kB 00:00:00 (19/22): selinux-policy-3.13.1-268.el7_9.2.noarch.rpm | 498 kB 00:00:00 (20/22): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00 (21/22): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00 (22/22): selinux-policy-targeted-3.13.1-268.el7_9.2.noarch.rpm | 7.0 MB 00:00:00 ------------------------------------------------------------------------------------------------------------ Total 40 MB/s | 117 MB 00:00:02 Retrieving key from https://download.docker.com/linux/centos/gpg Importing GPG key 0x621E9F35: Userid : "Docker Release (CE rpm) <docker@docker.com>" Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35 From : https://download.docker.com/linux/centos/gpg Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libseccomp-2.3.1-4.el7.x86_64 1/22 Installing : docker-scan-plugin-0.8.0-3.el7.x86_64 2/22 Installing : 1:docker-ce-cli-20.10.7-3.el7.x86_64 3/22 Installing : libcgroup-0.41-21.el7.x86_64 4/22 Installing : libselinux-utils-2.5-15.el7.x86_64 5/22 Installing : policycoreutils-2.5-34.el7.x86_64 6/22 Installing : selinux-policy-3.13.1-268.el7_9.2.noarch 7/22 Installing : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch 8/22 Installing : slirp4netns-0.4.3-4.el7_8.x86_64 9/22 Installing : audit-libs-python-2.8.5-4.el7.x86_64 10/22 Installing : libselinux-python-2.5-15.el7.x86_64 11/22 Installing : libsemanage-python-2.5-14.el7.x86_64 12/22 Installing : fuse3-libs-3.6.1-4.el7.x86_64 13/22 Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 14/22 Installing : setools-libs-3.3.8-4.el7.x86_64 15/22 Installing : python-IPy-0.75-6.el7.noarch 16/22 Installing : checkpolicy-2.5-8.el7.x86_64 17/22 Installing : policycoreutils-python-2.5-34.el7.x86_64 18/22 Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 19/22 setsebool: SELinux is disabled. Installing : containerd.io-1.4.6-3.1.el7.x86_64 20/22 Installing : 3:docker-ce-20.10.7-3.el7.x86_64 21/22 Installing : docker-ce-rootless-extras-20.10.7-3.el7.x86_64 22/22 Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 1/22 Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 2/22 Verifying : 3:docker-ce-20.10.7-3.el7.x86_64 3/22 Verifying : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch 4/22 Verifying : docker-ce-rootless-extras-20.10.7-3.el7.x86_64 5/22 Verifying : 1:docker-ce-cli-20.10.7-3.el7.x86_64 6/22 Verifying : checkpolicy-2.5-8.el7.x86_64 7/22 Verifying : policycoreutils-2.5-34.el7.x86_64 8/22 Verifying : python-IPy-0.75-6.el7.noarch 9/22 Verifying : libseccomp-2.3.1-4.el7.x86_64 10/22 Verifying : libselinux-utils-2.5-15.el7.x86_64 11/22 Verifying : policycoreutils-python-2.5-34.el7.x86_64 12/22 Verifying : setools-libs-3.3.8-4.el7.x86_64 13/22 Verifying : fuse3-libs-3.6.1-4.el7.x86_64 14/22 Verifying : docker-scan-plugin-0.8.0-3.el7.x86_64 15/22 Verifying : libsemanage-python-2.5-14.el7.x86_64 16/22 Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 17/22 Verifying : libselinux-python-2.5-15.el7.x86_64 18/22 Verifying : selinux-policy-3.13.1-268.el7_9.2.noarch 19/22 Verifying : audit-libs-python-2.8.5-4.el7.x86_64 20/22 Verifying : containerd.io-1.4.6-3.1.el7.x86_64 21/22 Verifying : libcgroup-0.41-21.el7.x86_64 22/22 Installed: docker-ce.x86_64 3:20.10.7-3.el7 Dependency Installed: audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.119.2-1.911c772.el7_8 containerd.io.x86_64 0:1.4.6-3.1.el7 docker-ce-cli.x86_64 1:20.10.7-3.el7 docker-ce-rootless-extras.x86_64 0:20.10.7-3.el7 docker-scan-plugin.x86_64 0:0.8.0-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 libcgroup.x86_64 0:0.41-21.el7 libseccomp.x86_64 0:2.3.1-4.el7 libselinux-python.x86_64 0:2.5-15.el7 libselinux-utils.x86_64 0:2.5-15.el7 libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils.x86_64 0:2.5-34.el7 policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 selinux-policy.noarch 0:3.13.1-268.el7_9.2 selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2 setools-libs.x86_64 0:3.3.8-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8 Complete!
5、 查看docker版本,验证是否验证成功
docker -v
[root@abc906093117 ~]# docker -v
Docker version 20.10.7, build f0df350
配置Docker镜像加速器
Docker默认会从官方的’Docker hub’仓库来下载Docker镜像,仓库的地址为https://hub.docker.com/。
但很显然,在国内下载官方仓库中的Dokcer镜像是非常慢的,因此需要配置Docker镜像加速器,有如下几种:
如果你用USTC,那么过程会比较简单。我使用的是阿里云镜像加速,但需要自己到阿里云控制台进行配置。
首先登陆阿里云,进入控制台,搜索’镜像’,选择‘容器镜像服务’
选择左侧工具栏中的‘镜像加速器’。
在这里我们可以看到,阿里云为我们提供的个人镜像加速地址。
同时,页面中有对应各个不同操作系统的配置方法,这里我选择CentOS系统,直接将红框内的命令复制到ssh控制台执行即可。
[root@abc906093117 ~]# sudo mkdir -p /etc/docker
[root@abc906093117 ~]# sudo tee /etc/docker/daemon.json <<-'EOF'
> {
> "registry-mirrors": ["https://tj3iost4.mirror.aliyuncs.com"]
> }
> EOF
{
"registry-mirrors": ["https://tj3iost4.mirror.aliyuncs.com"]
}
[root@abc906093117 ~]# sudo systemctl daemon-reload
[root@abc906093117 ~]# sudo systemctl restart docker
看一看Docker加速镜像中的配置文件是否已经成功更改为阿里云提供的个人镜像加速地址。
cat /etc/docker/daemon.json
[root@abc906093117 ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://tj3iost4.mirror.aliyuncs.com"]
}
[root@abc906093117 ~]#
这里呢,可以看到配置文件中已经写入了之前阿里云为我们提供的个人镜像加速地址。
启动:systemctl start docker
停止:systemctl stop docker
重启:systemctl restart docker
查看状态:systemctl status docker
开启开机自动启动:systemctl enable docker
查看帮助文档:docker --help
查看概要信息:docker info 该命令可以查看docker的官方镜像仓库和私人镜像仓库的地址,以及版本等信息。
docker images
[root@abc906093117 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
REPOSITORY 是镜像名称
TAG 是标签,多用来镜像版本区分
IMAGE ID 是镜像id,它是唯一的。
CREATED 是该镜像创建至今的时间。
SIZE 是镜像大小,单位为mb。
注意,这是从仓库中搜索镜像,而不是本地。
同时这是一个模糊搜索,将列出所有包括该字符串的镜像。
docker search 镜像名称
[root@abc906093117 ~]# docker search nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 15087 [OK] jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 2038 [OK] richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 815 [OK] jc21/nginx-proxy-manager Docker container for managing Nginx proxy ho… 203 linuxserver/nginx An Nginx container, brought to you by LinuxS… 147 tiangolo/nginx-rtmp Docker image with Nginx using the nginx-rtmp… 131 [OK] jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager 120 [OK] alfg/nginx-rtmp NGINX, nginx-rtmp-module and FFmpeg from sou… 101 [OK] bitnami/nginx Bitnami nginx Docker Image 98 [OK] nginxdemos/hello NGINX webserver that serves a simple page co… 70 [OK] privatebin/nginx-fpm-alpine PrivateBin running on an Nginx, php-fpm & Al… 56 [OK] nginx/nginx-ingress NGINX and NGINX Plus Ingress Controllers fo… 55 nginxinc/nginx-unprivileged Unprivileged NGINX Dockerfiles 39 staticfloat/nginx-certbot Opinionated setup for automatic TLS certs lo… 23 [OK] nginx/nginx-prometheus-exporter NGINX Prometheus Exporter for NGINX and NGIN… 19 schmunk42/nginx-redirect A very simple container to redirect HTTP tra… 19 [OK] centos/nginx-112-centos7 Platform for running nginx 1.12 or building … 15 centos/nginx-18-centos7 Platform for running nginx 1.8 or building n… 13 bitwarden/nginx The Bitwarden nginx web server acting as a r… 11 flashspys/nginx-static Super Lightweight Nginx Image 10 [OK] bitnami/nginx-ingress-controller Bitnami Docker Image for NGINX Ingress Contr… 9 [OK] mailu/nginx Mailu nginx frontend 8 [OK] devilbox/nginx-stable Devilbox's Nginx stable (based on official N… 4 ansibleplaybookbundle/nginx-apb An APB to deploy NGINX 2 [OK] wodby/nginx Generic nginx 1 [OK]
name列:镜像名
DESCRIPTION列:镜像描述
STARS列:用户评分,反应受欢迎程度
OFFICIAL列:是否为官方提供的
AUTOMATED列:是否为自动构建,表示为Docker hub自动构建出来的镜像
docker pull 镜像名
[root@abc906093117 ~]# docker pull linuxserver/nginx Using default tag: latest latest: Pulling from linuxserver/nginx 00fe9b963179: Pulling fs layer f23b92877416: Pulling fs layer a5bf9c523af4: Pulling fs layer 10f45b17b9ab: Waiting c583b34264f1: Waiting bfafa0ba1dc9: Waiting f6950568f047: Waiting 94b2f610d8cb: Waiting 0156770143cf: Waiting 5bd26da57aec: Waiting latest: Pulling from linuxserver/nginx 00fe9b963179: Pull complete f23b92877416: Pull complete a5bf9c523af4: Pull complete 10f45b17b9ab: Pull complete c583b34264f1: Pull complete bfafa0ba1dc9: Pull complete f6950568f047: Pull complete 94b2f610d8cb: Pull complete 0156770143cf: Pull complete 5bd26da57aec: Pull complete Digest: sha256:927ccbc3948b90b1e73329b17ef657311796aab5422e460f67984b6fc3994892 Status: Downloaded newer image for linuxserver/nginx:latest docker.io/linuxserver/nginx:latest
注意:如果当前有运行中的容器是根据该镜像所创建的,需要将该镜像的所有容器删除或停止。
docker rmi 镜像名称或镜像id
[root@abc906093117 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE linuxserver/nginx latest befde9691ea1 4 days ago 166MB [root@abc906093117 ~]# docker rmi linuxserver/nginx Untagged: linuxserver/nginx:latest Untagged: linuxserver/nginx@sha256:927ccbc3948b90b1e73329b17ef657311796aab5422e460f67984b6fc3994892 Deleted: sha256:befde9691ea141e2e27b1fdb7ea7e18e0c136ae63b5b99f5d6825ee5b20103aa Deleted: sha256:d4d89c763027a8353ec8a4cf60e44b89ab6a8d58175a5c64eb16d26e59fe5270 Deleted: sha256:f5a8b9afd2b85c58db2c8832ba35d252fbf1cad744b4152affee502fc1df03f1 Deleted: sha256:02c3904cb1d983ede259d2272f996f8525219dd7f1d23ac4fb1bf0e3b4508248 Deleted: sha256:97df1ab9056c80f6d1320e0b3361b2026b84892e09b3ebb492e2fadebf8dc958 Deleted: sha256:5ef971eb0248f78ad81fc7c3e894d72dc9259f0b81f8e6682e73cbc3540aa7d6 Deleted: sha256:58d8765ada49e3b3f2f9eddffc8c6daaafa7598c426f7c43a3b62af7413454eb Deleted: sha256:d79fd497d21bef068b351dc7ce16abadde90ca365eabdb57fcf772bd27d35fdb Deleted: sha256:0f1af12daf017ba89ac87134a9975873cf2771e41764923307089daa5b739237 Deleted: sha256:772502f624d1313f7ff0455757f5d898ec6246eb8f8452c609789be7b4243335 Deleted: sha256:02aa69f18a6ba498f8d6ca5041d79ec41958ca48a2fa532c71f3311f5c21082a
docker rmi ‘docker images -q’
容器是基于镜像去运行的,一个镜像可以创建多个容器。关系类似就类似于java中的类与对象。
docker run -参数名1 -参数名2 -参数名n --name=自定义容器名 镜像名称:镜像标签
[root@abc906093117 ~]# docker images (先查看已经拉取的镜像有哪些)
REPOSITORY TAG IMAGE ID CREATED SIZE
linuxserver/nginx latest befde9691ea1 6 days ago 166MB
[root@abc906093117 ~]# docker run -id --name=myNginxDocker linuxserver/nginx:latest (-i表示创建容器。-d代表后台守护式运行,不进入到这个容器的终端。镜像标签名为latest的话可以省略,此处我没省略)
4c7c6eeef68d352725bc8c6133284c550b1122b5e8b268eaa732dd40c277d0c9
[root@abc906093117 ~]# docker ps (查看当前正在运行的镜像)
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c7c6eeef68d linuxserver/nginx:latest "/init" 5 seconds ago Up 4 seconds 80/tcp, 443/tcp myNginxDocker
Docker的创建容器命令是’docker run‘配合一些参数来实现的,下面来介绍一下参数。
1 关于参数i
和t
的解释:
参数 -i
:表示创建容器
参数 -t:
表示容器启动后就进入该容器的命令行操作处,即分配一个伪终端,在这个伪终端里可以和容器外的宿主机一样进行命令操作。
当参数为’-it’时,则表示创建容器后立马进入该容器所分配的伪终端命令行。
2 容器命名参数:–name
为所创建的容器命名,如 --name=myNginxDocker
3 目录映射参数:-v
将容器的某个目录和宿主机的某个目录进行映射,形成一个映射关系。这类似于为VM虚拟机和宿主机之间所设置的共享文件夹。
4 守护式创建容器:-d
如果加上-d参数的话,则会创建一个守护式容器从而在后台运行。但这样创建后就不会自动进入容器的伪终端。
也就是说,如果不仅有-i,-t这两个参数,还有-d的话,并不会在创建容器后自动登录进入到伪终端。
5 端口映射:-p
用于容器和宿主机之间的端口映射,前者是宿主机端口,后者是容器内端口。可以使用多个-p来做多个端口的映射。
docker ps
[root@abc906093117 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c7c6eeef68d linuxserver/nginx:latest "/init" 5 seconds ago Up 4 seconds 80/tcp, 443/tcp myNginxDocker
docker ps -a
[root@abc906093117 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c7c6eeef68d linuxserver/nginx:latest "/init" 13 minutes ago Up 13 minutes 80/tcp, 443/tcp myNginxDocker
进入:docker exec -it 运行中的容器名 bash
退出(在伪终端内):exit
[root@abc906093117 ~]# docker exec -it myNginxDocker bash (如果镜像本身不支持伪终端,需要末尾加上bash才能显示伪终端)
root@4f45c0429061:/# exit (此时已经进入到了伪终端,输入exit退出)
exit
[root@abc906093117 ~]#
关于进入:
我们创建容器后,容器也的的确确在运行。但是,你也可以进入容器的伪终端来进行操作。需要注意的是,个别镜像本身是不支持伪终端的,如nginx镜像,因为它本身就是个应用,进入容器之后只能看到日志的输出,需要末尾加上bash才能显示伪终端。
但如果你的镜像是centos这类的话,那么进入该容器后是能够直接以终端形式来操作的。
关于退出:
如果你的容器不是以后台守护创建运行的话,那么执行exit退出伪终端将会直接停止运行该容器。
docker stop 容器名/容器id
[root@abc906093117 ~]# docker stop myNginxDocker
myNginxDocker
docker start 容器名/容器id
[root@abc906093117 ~]# docker start myNginxDocker
myNginxDocker
docker rm 容器名/容器id
[root@abc906093117 ~]# docker rm myNginxDocker
myNginxDocker
OR.从宿主机拷贝文件到容器中
docker cp 需要拷贝的文件或文件夹 容器名称/容器id:容器目录
[root@abc906093117 ~]# cat > test.txt (现在宿主机当前的目录下创建一个'test.txt'文件)
textFileForDockerFileCopyTest
[root@abc906093117 ~]# dir (搜索下当前目录是否存在创建的文件)
test.txt
[root@abc906093117 ~]# docker cp test.txt myNginxDocker:/ (这里拷贝文件到容器中,‘/'是我所指定的、该容器的目录。当前宿主机命令行是在'root'目录,而'text.txt'文件也是在root目录下,所以不需要指定绝对路径)
[root@abc906093117 ~]# docker exec -it myNginxDocker bash (进入到容器终端)
root@83e0c8d4cc31:/# dir (查看当前目录下的文件有哪些)
app config dev etc init libexec mnt proc run srv test.txt usr
bin defaults docker-mods home lib media opt root sbin sys tmp var
root@83e0c8d4cc31:/# cat test.txt (打开看一下)
textFileForDockerFileCopyTest
OR.从容器拷贝文件到宿主机中
*docker cp 容器名称/容器id:文件或目录的绝对路径 拷贝到宿主机后的文件名
root@83e0c8d4cc31:/# cat > testFile.txt (在容器中创建文件'testFile.txt')
testDockerCopyForLocalServer
root@83e0c8d4cc31:/# dir (看下当前目录存不存在它)
app config dev etc init libexec mnt proc run srv testFile.txt usr
bin defaults docker-mods home lib media opt root sbin sys tmp var
root@83e0c8d4cc31:/# exit (退出容器的伪终端,返回到宿主机)
exit
[root@abc906093117 ~]# docker cp myNginxDocker:/testFile.txt test.txt (从容器’myNginxDocker'拷贝文件,绝对路径为'/testFile.txt' ,文件拷贝到宿主机后命名为'test.txt'
[root@abc906093117 ~]# dir
test.txt
[root@abc906093117 ~]# cat test.txt (查看一下文件内容,拷贝成功)
testDockerCopyForLocalServer
关于目录映射挂载,前面已经说过了,就是指定一个容器的目录和一个宿主机的目录进行映射,类似共享文件夹。
需要注意的是,目录挂载映射只能在创建容器时指定,对于已经创建后的容器无法指定。
如果你的要映射的目录是多级的,可能会提示你权限不足。这是因为centos系统中安全模块‘selinux’把权限禁掉了。需要添加参数–privileged=true
docker run -参数名1 -参数名2 -参数名n -v
宿主机目录绝对路径:
容器目录绝对路径 --name=自定义容器名 镜像名称:镜像标签
[root@abc906093117 ~]# docker rm myNginxDocker (先删除此前创建的容器) myNginxDocker [root@abc906093117 ~]# mkdir myDirectory (在当前文件夹创建myDirectory文件夹,这个文件夹将被用到后面的目录映射中。) [root@abc906093117 ~]# cd myDirectory (进入该目录) [root@abc906093117 myDirectory]# cat > directoryMappingFile.txt (在该目录下再创建一个文本用于测试) directoryMappingFileTextForTest [root@abc906093117 myDirectory]# cd ../ (返回到上级目录) [root@abc906093117 ~]# pwd (查看当前所在目录的路径) /root [root@abc906093117 ~]# docker images (查看所有本地的镜像,用于创建容器) REPOSITORY TAG IMAGE ID CREATED SIZE linuxserver/nginx latest befde9691ea1 8 days ago 166MB [root@abc906093117 ~]# docker run -i -d -v /root/myDirectory:/directoryMappingTest --name=myNginxDocker linuxserver/nginx:latest (以后台守护方式创建容器‘myNginxDocker’,镜像为‘linuxserver/nginx’,指定宿主机目录‘/root/myDirectory’同容器目录‘/directoryMappingTest’进行映射,如果容器不存在这个目录会自动创建) 1f9649eaf496d40cc36ab0c41562bac848ee228a2b3d91fde3b9f004107c3d39 [root@abc906093117 ~]# docker exec -it myNginxDocker bash (进入容器伪终端) root@1f9649eaf496:/# cd directoryMappingTest (进入尝试进入映射目录) root@1f9649eaf496:/directoryMappingTest# cat directoryMappingFile.txt (进入成功,尝试查看该映射目录下的文本文件) directoryMappingFileTextForTest ## 接下来,我们试试添加 --privileged=true 来创建容器。 root@1f9649eaf496:/directoryMappingTest# exit exit [root@abc906093117 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1f9649eaf496 linuxserver/nginx:latest "/init" 20 minutes ago Up 20 minutes 80/tcp, 443/tcp myNginxDocker [root@abc906093117 ~]# docker run -i -d --privileged=true -v /root/myDirectory:/directoryMappingTest --name=myNginxDockerTwo linuxserver/nginx:latest (通过--privileged=true参数来创建容器,可以解决多级目录映射时权限不足的问题) 775b6dbf16a566a06b8c423d45d2c9c609647f554933c15583fda3d8848f5d20 [root@abc906093117 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 775b6dbf16a5 linuxserver/nginx:latest "/init" 7 seconds ago Up 5 seconds 80/tcp, 443/tcp myNginxDockerTwo 1f9649eaf496 linuxserver/nginx:latest "/init" 21 minutes ago Up 21 minutes 80/tcp, 443/tcp myNginxDocker [root@abc906093117 ~]#
查看容器信息,会列出包括容器ip在内的所以详细信息:
docker inspect 容器名称或容器id
仅仅查看容器ip:
docker inspect --format=’{{.NetworkSettings.IPAddress}}’ 容器名称或容器id
[root@abc906093117 ~]# docker inspect myNginxDocker (查看容器’myNginxDocker‘的全部信息) [ { "Id": "1f9649eaf496d40cc36ab0c41562bac848ee228a2b3d91fde3b9f004107c3d39", "Created": "2021-07-03T09:25:47.819268643Z", "Path": "/init", "Args": [], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 12626, "ExitCode": 0, "Error": "", "StartedAt": "2021-07-03T09:25:49.29469861Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "sha256:befde9691ea141e2e27b1fdb7ea7e18e0c136ae63b5b99f5d6825ee5b20103aa", "ResolvConfPath": "/var/lib/docker/containers/1f9649eaf496d40cc36ab0c41562bac848ee228a2b3d91fde3b9f004107c3d39/resolv.conf", "HostnamePath": "/var/lib/docker/containers/1f9649eaf496d40cc36ab0c41562bac848ee228a2b3d91fde3b9f004107c3d39/hostname", "HostsPath": "/var/lib/docker/containers/1f9649eaf496d40cc36ab0c41562bac848ee228a2b3d91fde3b9f004107c3d39/hosts", "LogPath": "/var/lib/docker/containers/1f9649eaf496d40cc36ab0c41562bac848ee228a2b3d91fde3b9f004107c3d39/1f9649eaf496d40cc36ab0c41562bac848ee228a2b3d91fde3b9f004107c3d39-json.log", "Name": "/myNginxDocker", "RestartCount": 0, "Driver": "overlay2", "Platform": "linux", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": { "Binds": [ "/root/myDirectory:/directoryMappingTest" ], "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "default", "PortBindings": {}, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "CgroupnsMode": "host", "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "private", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [ 0, 0 ], "Isolation": "", "CpuShares": 0, "Memory": 0, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": [], "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DeviceRequests": null, "KernelMemory": 0, "KernelMemoryTCP": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": null, "OomKillDisable": false, "PidsLimit": null, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0, "MaskedPaths": [ "/proc/asound", "/proc/acpi", "/proc/kcore", "/proc/keys", "/proc/latency_stats", "/proc/timer_list", "/proc/timer_stats", "/proc/sched_debug", "/proc/scsi", "/sys/firmware" ], "ReadonlyPaths": [ "/proc/bus", "/proc/fs", "/proc/irq", "/proc/sys", "/proc/sysrq-trigger" ] }, "GraphDriver": { "Data": { "LowerDir": "/var/lib/docker/overlay2/87edbd7c430c674d0a967babbba63420b666de524f5de63f9f6b8f439b947f1a-init/diff:/var/lib/docker/overlay2/846aaa36708b7551e6f39a42d0b820bf42111960e1c7528ebfe1990214a4d998/diff:/var/lib/docker/overlay2/3bd7890cd72337042ed24729185a124d33f13a8afbb7428db3186fb179a06045/diff:/var/lib/docker/overlay2/3eaaeee0ce0ff21d68a2e2960e671597d89922228b22f885649cc19ced36855a/diff:/var/lib/docker/overlay2/be54993f03831e668b4adc479c5f3e1c3fb00de356f8f018f3b570709887c463/diff:/var/lib/docker/overlay2/dc0c86346fd84334b851a6195ee528ee6f5af2228a4c42ae9903956b25ebfa93/diff:/var/lib/docker/overlay2/0eb930019eb5db4b689065352aa664bda490c8a590663bbfef422ff5e6d8e425/diff:/var/lib/docker/overlay2/f29fd2610ea1c38f7b2c845e801436fcde9d91b6fe2ff92a96d03202750ce72e/diff:/var/lib/docker/overlay2/67b85512f6acb9cec6c732555897026b23fa03d07b3f834284d61e6793d6a754/diff:/var/lib/docker/overlay2/f0a286263329d2af6afcb9e1e3a2e82f755afd9c9680814dea99f90b1f04ddc4/diff:/var/lib/docker/overlay2/311aef40cce942e4058207de0026402f0f02406eeb31f82f2defe9b8b5e65de7/diff", "MergedDir": "/var/lib/docker/overlay2/87edbd7c430c674d0a967babbba63420b666de524f5de63f9f6b8f439b947f1a/merged", "UpperDir": "/var/lib/docker/overlay2/87edbd7c430c674d0a967babbba63420b666de524f5de63f9f6b8f439b947f1a/diff", "WorkDir": "/var/lib/docker/overlay2/87edbd7c430c674d0a967babbba63420b666de524f5de63f9f6b8f439b947f1a/work" }, "Name": "overlay2" }, "Mounts": [ { "Type": "bind", "Source": "/root/myDirectory", "Destination": "/directoryMappingTest", "Mode": "", "RW": true, "Propagation": "rprivate" }, { "Type": "volume", "Name": "79c33fef03ea5e85521e89f7b949f9822ebd746d50f61556242450339d5e1d1a", "Source": "/var/lib/docker/volumes/79c33fef03ea5e85521e89f7b949f9822ebd746d50f61556242450339d5e1d1a/_data", "Destination": "/config", "Driver": "local", "Mode": "", "RW": true, "Propagation": "" } ], "Config": { "Hostname": "1f9649eaf496", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": { "443/tcp": {}, "80/tcp": {} }, "Tty": false, "OpenStdin": true, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "PS1=$(whoami)@$(hostname):$(pwd)\\$ ", "HOME=/root", "TERM=xterm", "S6_BEHAVIOUR_IF_STAGE2_FAILS=2" ], "Cmd": null, "Image": "linuxserver/nginx:latest", "Volumes": { "/config": {} }, "WorkingDir": "", "Entrypoint": [ "/init" ], "OnBuild": null, "Labels": { "build_version": "Linuxserver.io version:- 1.18.0-r15-ls136 Build-date:- 2021-06-24T10:00:40-04:00", "maintainer": "aptalca", "org.opencontainers.image.authors": "linuxserver.io", "org.opencontainers.image.created": "2021-06-24T10:00:40-04:00", "org.opencontainers.image.description": "[Nginx](https://nginx.org/) is a simple webserver with php support. The config files reside in for easy user customization.", "org.opencontainers.image.documentation": "https://docs.linuxserver.io/images/docker-nginx", "org.opencontainers.image.licenses": "GPL-3.0-only", "org.opencontainers.image.ref.name": "ae50b5e375567844e33580eaa45ff2abc04b8327", "org.opencontainers.image.revision": "ae50b5e375567844e33580eaa45ff2abc04b8327", "org.opencontainers.image.source": "https://github.com/linuxserver/docker-nginx", "org.opencontainers.image.title": "Nginx", "org.opencontainers.image.url": "https://github.com/linuxserver/docker-nginx/packages", "org.opencontainers.image.vendor": "linuxserver.io", "org.opencontainers.image.version": "1.18.0-r15-ls136" } }, "NetworkSettings": { "Bridge": "", "SandboxID": "b2c48a4290ea1d582be3bd1568f467976393fcda7e0aa5f7370f95aff1cea901", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": { "443/tcp": null, "80/tcp": null }, "SandboxKey": "/var/run/docker/netns/b2c48a4290ea", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "0c7acd079f5abfcaad40576d529cfc258d47d5232c4882435628008f5913e9db", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "MacAddress": "02:42:ac:11:00:02", "Networks": { "bridge": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "1d531969e1a2a115dad3edecfa5a75b041626620fb37a476efea1a226e149846", "EndpointID": "0c7acd079f5abfcaad40576d529cfc258d47d5232c4882435628008f5913e9db", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02", "DriverOpts": null } } } } ] [root@abc906093117 ~]# docker inspect --format='{{.NetworkSettings.IPAddress}}' myNginxDocker (仅查看容器ip) 172.17.0.2
第一步,搜索镜像
[root@abc906093117 ~]# docker search mysql NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 11082 [OK] mariadb MariaDB Server is a high performing open sou… 4199 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Create… 823 [OK] centos/mysql-57-centos7 MySQL 5.7 SQL database server 88 mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 88 centurylink/mysql Image containing mysql. Optimized to be link… 59 [OK] databack/mysql-backup Back up mysql databases to... anywhere! 44 deitch/mysql-backup REPLACED! Please use http://hub.docker.com/r… 41 [OK] prom/mysqld-exporter 39 [OK] tutum/mysql Base docker image to run a MySQL database se… 35 linuxserver/mysql A Mysql container, brought to you by LinuxSe… 30 schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 29 [OK] mysql/mysql-router MySQL Router provides transparent routing be… 21 centos/mysql-56-centos7 MySQL 5.6 SQL database server 20 arey/mysql-client Run a MySQL client from a docker container 17 [OK] fradelg/mysql-cron-backup MySQL/MariaDB database backup using cron tas… 14 [OK] genschsa/mysql-employees MySQL Employee Sample Database 7 [OK] yloeffler/mysql-backup This image runs mysqldump to backup data usi… 7 [OK] openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image… 6 devilbox/mysql Retagged MySQL, MariaDB and PerconaDB offici… 3 ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 2 [OK] jelastic/mysql An image of the MySQL database server mainta… 1 widdpim/mysql-client Dockerized MySQL Client (5.7) including Curl… 1 [OK] vitess/mysqlctld vitess/mysqlctld 1 [OK] centos/mysql-80-centos7 MySQL 8.0 SQL database server
第二步,拉取mysql镜像。这里选择的是centos/mysql-57-centos7这个镜像
[root@abc906093117 ~]# docker pull centos/mysql-57-centos7 Using default tag: latest latest: Pulling from centos/mysql-57-centos7 d8d02d457314: Pull complete a11069b6e245: Pull complete 596303fb1aa3: Pull complete a29499e779a7: Pull complete 17d1a52c2e00: Pull complete ed24591227fe: Pull complete de0ad46e3ed9: Pull complete c62e4a984a9c: Pull complete 01d54c6bda68: Pull complete Digest: sha256:e08ee4d43b7356607685b69bde6335e27cf20c020f345b6c6c59400183882764 Status: Downloaded newer image for centos/mysql-57-centos7:latest docker.io/centos/mysql-57-centos7:latest
第三步,创建mysql容器。
docker run -i -d -p 4205:3306
-e MYSQL_ROOT_PASSWORD=root123456
--name=myMysqlDocker centos/mysql-57-centos7:latest
[root@abc906093117 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
linuxserver/nginx latest befde9691ea1 9 days ago 166MB
centos/mysql-57-centos7 latest f83a2938370c 21 months ago 452MB
[root@abc906093117 ~]# docker run -i -d -p 4205:3306 -e MYSQL_ROOT_PASSWORD=root123456 --name=myMysqlDocker centos/mysql-57-centos7:latest (通过'centos/mysql-57-centos7'镜像创建mysql容器。容器起名为'myMysqlDocker'。通过设置环境变量来指定数据库root用户密码为'root123456'。指定宿主机的4205端口和容器的3306端口映射。
718c6b9ad5fdf03dfbd497fd507e89104345c63b4baf0500daa186e7b9b6dd05
参数解释:
-i
创建容器-d
以后台守护式创建-p
将容器端口和宿主机端口进行映射,左边为宿主机端口,右边为容器中mysql的端口-e
表示添加环境变量,MYSQL_ROOT_PASSWORD这个变量用于设定mysql的root权限密码。--name
用于给容器起个名。第四步,查看状态
可以看到在’PORTS‘这一栏,有显示端口映射信息。
[root@abc906093117 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
718c6b9ad5fd centos/mysql-57-centos7:latest "container-entrypoin…" 18 minutes ago Up 2 seconds 0.0.0.0:4205->3306/tcp, :::4205->3306/tcp myMysqlDocker
第五步,尝试进入伪终端
[root@abc906093117 ~]# docker exec -it myMysqlDocker bash
bash-4.2$
第六步,尝试在本机连接在VPS的Docker容器中建立的Mysql数据库。
可以看到,连接成功了!
一,搜索tomcat镜像。
[root@abc906093117 ~]# docker search tomcat NAME DESCRIPTION STARS OFFICIAL AUTOMATED tomcat Apache Tomcat is an open source implementati… 3060 [OK] tomee Apache TomEE is an all-Apache Java EE certif… 90 [OK] dordoka/tomcat Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 base… 57 [OK] kubeguide/tomcat-app Tomcat image for Chapter 1 30 consol/tomcat-7.0 Tomcat 7.0.57, 8080, "admin/admin" 18 [OK] cloudesire/tomcat Tomcat server, 6/7/8 15 [OK] aallam/tomcat-mysql Debian, Oracle JDK, Tomcat & MySQL 13 [OK] arm32v7/tomcat Apache Tomcat is an open source implementati… 11 rightctrl/tomcat CentOS , Oracle Java, tomcat application ssl… 6 [OK] maluuba/tomcat7-java8 Tomcat7 with java8. 6 unidata/tomcat-docker Security-hardened Tomcat Docker container. 5 [OK] arm64v8/tomcat Apache Tomcat is an open source implementati… 3 amd64/tomcat Apache Tomcat is an open source implementati… 3 jelastic/tomcat An image of the Tomcat Java application serv… 2 cfje/tomcat-resource Tomcat Concourse Resource 2 oobsri/tomcat8 Testing CI Jobs with different names. 2 fabric8/tomcat-8 Fabric8 Tomcat 8 Image 2 [OK] picoded/tomcat7 tomcat7 with jre8 and MANAGER_USER / MANAGER… 1 [OK] chenyufeng/tomcat-centos tomcat基于centos6的镜像 1 [OK] 99taxis/tomcat7 Tomcat7 1 [OK] camptocamp/tomcat-logback Docker image for tomcat with logback integra… 1 [OK] ppc64le/tomcat Apache Tomcat is an open source implementati… 1 secoresearch/tomcat-varnish Tomcat and Varnish 5.0 0 [OK] s390x/tomcat Apache Tomcat is an open source implementati… 0 softwareplant/tomcat Tomcat images for jira-cloud testing 0 [OK]
二,选择名为‘tomcat’的镜像来拉取
[root@abc906093117 ~]# docker pull tomcat Using default tag: latest latest: Pulling from library/tomcat 0bc3020d05f1: Pull complete a110e5871660: Pull complete 83d3c0fa203a: Pull complete a8fd09c11b02: Pull complete 96ebf1506065: Pull complete b8bf70f9cc4d: Pull complete 3f6da67b9e68: Pull complete 257407776119: Pull complete 7bd0a187fb92: Pull complete 307fc4df04c9: Pull complete Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b Status: Downloaded newer image for tomcat:latest docker.io/library/tomcat:latest
三,创建Tomcat容器
docker run -id -v /root/tomcatDockerFile:/usr/locat/tomcat/webapps
-p 8081:8080
--name=myTomcatDocker tomcat:latest
[root@abc906093117 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest 36ef696ea43d 40 hours ago 667MB
centos/mysql-57-centos7 latest f83a2938370c 21 months ago 452MB
[root@abc906093117 ~]# docker run -id -v /root/tomcatDockerFile:/usr/locat/tomcat/webapps -p 8081:8080 --name=myTomcatDocker tomcat:latest
859c39421a3b92dbab1bcd7fce8a1d757d4c705106e8c967bfb82cb79c81ffce
参数解释:
-i
创建容器-d
以后台守护式创建-p
将容器端口和宿主机端口进行映射,左边为宿主机端口,右边为容器中tomcat的端口-v
目录映射,左边为宿主机目录,右边为tomcat容器目录。需要注意的是,/usr/locat/tomcat/webapps目录本身在tomcat容器里是已经存在的,因此将来我们部署项目时,就可以直接在宿主机来把项目war包放在tomcat的webapps目录下。--name
用于给容器起个名。四. 使用自己电脑访问tomcat
一.搜索Nginx镜像
[root@abc906093117 ~]# docker search nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 15111 [OK] jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 2037 [OK] richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 816 [OK] jc21/nginx-proxy-manager Docker container for managing Nginx proxy ho… 209 linuxserver/nginx An Nginx container, brought to you by LinuxS… 147 tiangolo/nginx-rtmp Docker image with Nginx using the nginx-rtmp… 132 [OK] jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager 120 [OK] alfg/nginx-rtmp NGINX, nginx-rtmp-module and FFmpeg from sou… 101 [OK] nginxdemos/hello NGINX webserver that serves a simple page co… 70 [OK] privatebin/nginx-fpm-alpine PrivateBin running on an Nginx, php-fpm & Al… 56 [OK] nginx/nginx-ingress NGINX and NGINX Plus Ingress Controllers fo… 55 nginxinc/nginx-unprivileged Unprivileged NGINX Dockerfiles 41 staticfloat/nginx-certbot Opinionated setup for automatic TLS certs lo… 23 [OK] schmunk42/nginx-redirect A very simple container to redirect HTTP tra… 19 [OK] nginx/nginx-prometheus-exporter NGINX Prometheus Exporter for NGINX and NGIN… 19 nginxproxy/nginx-proxy Automated Nginx reverse proxy for docker con… 15 centos/nginx-112-centos7 Platform for running nginx 1.12 or building … 15 centos/nginx-18-centos7 Platform for running nginx 1.8 or building n… 13 bitwarden/nginx The Bitwarden nginx web server acting as a r… 11 flashspys/nginx-static Super Lightweight Nginx Image 10 [OK] mailu/nginx Mailu nginx frontend 9 [OK] navidonskis/nginx-php5.6 Docker nginx + php5.6 on Ubuntu 7 [OK] sophos/nginx-vts-exporter Simple server that scrapes Nginx vts stats a… 7 [OK] ansibleplaybookbundle/nginx-apb An APB to deploy NGINX 2 [OK] wodby/nginx Generic nginx 1 [OK]
二.拉取镜像’ningx’
[root@abc906093117 ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
b4d181a07f80: Pull complete
edb81c9bc1f5: Pull complete
b21fed559b9f: Pull complete
03e6a2452751: Pull complete
b82f7f888feb: Pull complete
5430e98eba64: Pull complete
Digest: sha256:47ae43cdfc7064d28800bc42e79a429540c7c80168e8c8952778c0d5af1c09db
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
三.创建Nginx容器
docker run -i -d -p 81:80
--name=myNginxDocker nginx:latest
[root@abc906093117 ~]# docker run -i -d -p 81:80 --name=myNginxDocker nginx:latest
bc5517dcdad940d885808cda468c93c5e234a7649562aa3a94ca15f9aadc8f52
参数解释:
-i
创建容器-d
以后台守护式创建-p
将容器端口和宿主机端口进行映射,左边为宿主机端口,右边为容器中nginx的端口--name
用于给容器起个名。四.关于nginx配置相关。
我们部署项目,肯定是需要将资源和ngxin.conf配置文件放到容器里头的。
那么这就需要我们进入容器里头,来查看一下这个nginx容器的目录结构了。
通过docker exec 命令进入到nginx容器后,我们访问/etc目录,然后通过dir命令,就能列出etc当前的目录有哪些,其中有nginx目录
[root@abc906093117 ~]# docker exec -i -t myNginxDocker bash
root@bc5517dcdad9:/# cd /etc
root@bc5517dcdad9:/etc# dir
adduser.conf debconf.conf gai.conf hosts ld.so.conf.d motd passwd rc4.d selinux systemd
alternatives debian_version group init.d ldap mtab passwd- rc5.d shadow terminfo
apt default group- inputrc libaudit.conf nginx profile rc6.d shadow- timezone
bash.bashrc deluser.conf gshadow issue localtime nsswitch.conf profile.d rcS.d shells ucf.conf
bindresvport.blacklist dpkg gshadow- issue.net login.defs opt rc0.d resolv.conf skel update-motd.d
ca-certificates environment gss kernel logrotate.d os-release rc1.d rmt ssl xattr.conf
ca-certificates.conf fonts host.conf ld.so.cache machine-id pam.conf rc2.d securetty subgid
cron.daily fstab hostname ld.so.conf mke2fs.conf pam.d rc3.d security subuid
我们再进入这个nginx目录,再通过dir命令查看,就发现了一个让我们熟悉的文件,没错,就是nginx的配置文件‘nginx.conf’。
root@bc5517dcdad9:/etc# cd nginx
root@bc5517dcdad9:/etc/nginx# dir
conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params
打开nginx.conf看一下
root@bc5517dcdad9:/etc/nginx# cat nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; }
但是,如果一个个在容器里头配,不是很麻烦吗?所以这里建议大家在创建容器时指定好映射目录。或者是通过docker cp命令来拷贝.
这里顺便补充一下,nginx的配置路径大致是下面三个:
五.使用自己电脑访问Nginx
一.搜索Redis镜像
[root@abc906093117 ~]# docker search redis NAME DESCRIPTION STARS OFFICIAL AUTOMATED redis Redis is an open source key-value store that… 9639 [OK] sameersbn/redis 83 [OK] grokzen/redis-cluster Redis cluster 3.0, 3.2, 4.0, 5.0, 6.0, 6.2 78 rediscommander/redis-commander Alpine image for redis-commander - Redis man… 61 [OK] redislabs/redisearch Redis With the RedisSearch module pre-loaded… 34 kubeguide/redis-master redis-master with "Hello World!" 33 redislabs/redisinsight RedisInsight - The GUI for Redis 32 redislabs/redis Clustered in-memory database engine compatib… 31 oliver006/redis_exporter Prometheus Exporter for Redis Metrics. Supp… 28 arm32v7/redis Redis is an open source key-value store that… 24 redislabs/rejson RedisJSON - Enhanced JSON data type processi… 23 redislabs/redisgraph A graph database module for Redis 15 [OK] arm64v8/redis Redis is an open source key-value store that… 14 redislabs/redismod An automated build of redismod - latest Redi… 14 [OK] redislabs/rebloom A probablistic datatypes module for Redis 12 [OK] webhippie/redis Docker images for Redis 11 [OK] s7anley/redis-sentinel-docker Redis Sentinel 10 [OK] insready/redis-stat Docker image for the real-time Redis monitor… 10 [OK] goodsmileduck/redis-cli redis-cli on alpine 9 [OK] redislabs/redistimeseries A time series database module for Redis 9 centos/redis-32-centos7 Redis in-memory data structure store, used a… 5 clearlinux/redis Redis key-value data structure server with t… 3 wodby/redis Redis container image with orchestration 1 [OK] tiredofit/redis Redis Server w/ Zabbix monitoring and S6 Ove… 1 [OK] xetamus/redis-resource forked redis-resource 0 [OK]
二.拉取镜像’redis’
[root@abc906093117 ~]# docker pull redis
Using default tag: latest
latest: Pulling from library/redis
b4d181a07f80: Already exists
86e428f79bcb: Pull complete
ba0d0a025810: Pull complete
ba9292c6f77e: Pull complete
b96c0d1da602: Pull complete
5e4b46455da3: Pull complete
Digest: sha256:7c540ceff53f0522f6b1c264d8142df08316173d103586ddf51ed91ca49deec8
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest
三.创建容器
docker run -i -d -p 6380:6379
--name=myRedisDocker redis:latest
[root@abc906093117 ~]# docker run -i -d -p 6380:6379 --name=myRedisDocker redis:latest
074e6d3c2e46ab4a266fd4c1bdff3581e1816d6ec955ab4264aad0f243268749
参数解释:
-i
创建容器-d
以后台守护式创建-p
将容器端口和宿主机端口进行映射,左边为宿主机端口,右边为容器中redis的端口--name
用于给容器起个名。四.用自己电脑的Redis客户端进行访问
访问成功!
注意:镜像名称必须为小写。
docker commit 已存在的容器名 自定义镜像名
[root@abc906093117 ~]# docker ps -a (查看已经创建了的容器)
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1388723764b0 nginx:latest "/docker-entrypoint.…" 20 seconds ago Up 13 seconds 0.0.0.0:81->80/tcp, :::81->80/tcp myNginxDocker
[root@abc906093117 ~]# docker commit myNginxDocker nginximage (将名为'myNginxDocker'的容器保存为镜像,镜像命名为‘nginximage‘)
sha256:2373291d219fe01c1efd943876c7418865256b3ceb3cafe4115c7aca413282ad
[root@abc906093117 ~]# docker images (再查看本地镜像,发现之前保存的镜像’nginximage‘是已经在本地了的)
REPOSITORY TAG IMAGE ID CREATED SIZE
nginximage latest 2373291d219f 2 minutes ago 133MB
nginx latest 4f380adfc10f 11 days ago 133MB
我们可以将镜像进行备份,也就是打包为tar压缩文件。这样方便我们将该镜像部署在其它服务器。
这里我就以之前的’nginximage‘镜像为例子。
docker save -o 自定义tar文件名.tar 要被备份的镜像名
[root@abc906093117 ~]# docker save -o nginxImageBackup.tar nginximage (将镜像’nginximage‘备份打包为tar压缩文件,命名为’nginxImageBackup.tar‘)
[root@abc906093117 ~]# ll (查看是否备份成功,可以看到已经存在)
total 134184
-rw------- 1 root root 137402880 Jul 4 16:59 nginxImageBackup.tar
当你把已经备份好了、打包为tar压缩文件的镜像迁移到另一个服务器后,你需要将该tar压缩文件还原为镜像才能使用,这个步骤叫做镜像还原。
*docker load -i 要被还原的镜像tar压缩包文件名 *
[root@abc906093117 ~]# docker ps (查看运行中的容器) CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1388723764b0 nginx:latest "/docker-entrypoint.…" 15 minutes ago Up 15 minutes 0.0.0.0:81->80/tcp, :::81->80/tcp myNginxDocker [root@abc906093117 ~]# docker stop myNginxDocker (停止运行该容器) myNginxDocker [root@abc906093117 ~]# docker rm myNginxDocker (删除该容器) myNginxDocker [root@abc906093117 ~]# docker rmi nginx (删除该容器的镜像) Untagged: nginx:latest Untagged: nginx@sha256:47ae43cdfc7064d28800bc42e79a429540c7c80168e8c8952778c0d5af1c09db [root@abc906093117 ~]# docker rmi nginximage (删除之前根据nginx容器来保存的镜像) Untagged: nginximage:latest Deleted: sha256:2373291d219fe01c1efd943876c7418865256b3ceb3cafe4115c7aca413282ad Deleted: sha256:8e5ec162bb2a88256baa9811f8e56ef83e0248830c4f3e7e3c19848c3cc4f21c Deleted: sha256:4f380adfc10f4cd34f775ae57a17d2835385efd5251d6dfe0f246b0018fb0399 Deleted: sha256:2855bbcefcf95050e64049447e99e77efa2bff32374e586982d69be4612467ce Deleted: sha256:bad169ad8b30eab551acbb8cd8fbdcd824528189e3dd0cc52dd88a37bbf121cd Deleted: sha256:36d83ebf5fec7ae1be4c431f0945f2dbe6828ecdc936c604daa48f17c0b50ed7 Deleted: sha256:b4c9a251dc81d52dd1cca9b4c69ca9e4db602a9a7974019f212846577f739699 Deleted: sha256:038ca5b801cea48e9f40f6ffb4cda61a2fe0b6b0f378a7434a0d39d2575a4082 Deleted: sha256:764055ebc9a7a290b64d17cf9ea550f1099c202d83795aa967428ebdf335c9f7 [root@abc906093117 ~]# docker images (查看当前本地镜像,为空) REPOSITORY TAG IMAGE ID CREATED SIZE [root@abc906093117 ~]# docker load -i nginxImageBackup.tar (从tar压缩文件’nginxImageBackup.tar‘来还原之前备份的镜像。 764055ebc9a7: Loading layer 72.53MB/72.53MB 2418679ca01f: Loading layer 64.81MB/64.81MB cf388fcf3527: Loading layer 3.072kB/3.072kB 165eb6c3c0d3: Loading layer 4.096kB/4.096kB b50a193ebf2e: Loading layer 3.584kB/3.584kB c6d74dcb7fe7: Loading layer 7.168kB/7.168kB 9b1398c44aa0: Loading layer 12.8kB/12.8kB Loaded image: nginximage:latest [root@abc906093117 ~]# docker images (查看当前本地镜像,可以看到存在了) REPOSITORY TAG IMAGE ID CREATED SIZE nginximage latest 2373291d219f 22 minutes ago 133MB [root@abc906093117 ~]# docker run -i -d -p 81:80 --name=myNginxDocker nginximage:latest (通过该镜像来创建容器试试看) f810e8cef7b84fd3373930abae16c6da667cb3bd050972ddd36007596f20eec5 [root@abc906093117 ~]# docker ps (查看当前正在运行的容器,可以看到通过此前还原过来的镜像,去创建出来的容器已经在运行了) CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f810e8cef7b8 nginximage:latest "/docker-entrypoint.…" 6 seconds ago Up 3 seconds 0.0.0.0:81->80/tcp, :::81->80/tcp myNginxDocker
首先我们需要知道什么是基础镜像和最终镜像。
所谓基础镜像,比如我拉取一个ElasticSearch镜像,
但是ElasticSearch是基于Jdk来运行的,所以这个ES镜像必定是基于Jdk镜像的基础上来实现的。
因此,此处jdk镜像相对于ES镜像就是基础镜像;es镜像相对于jdk镜像则是最终镜像。
又比如,我们后期需要在这个ElasticSearch镜像上装上了一个微服务项目去跑,并构建成为了一个新的镜像
那么这个镜像相对于ES镜像就是最终镜像,es镜像则成为了基础镜像。
Dockerfile是由一系列命令和参数所构成的脚本,这些命令和参数将应用于一个基础镜像,并最终创建为一个新的镜像。
常用命令如下:
命令 | 详解 |
---|---|
FROM 镜像名称:镜像标签 | 表示定义通过哪个基础镜像来进行构建,如果本地不存在该镜像,则进行拉取 |
MAINTAINER 姓名 | 用来声明镜像的创建者,可省略。 |
ENV 环境变量键名 环境变量数值 | 声明环境的变量,可声明多个 。单次定义单个变量时,格式为ENV KEY VALUE/例如:ENV JAVA_HOME /usr/local/java/jdk1.8.0_291 单次定义多个变量时,格式为env key1=value1 key2=value2 例如:ENV JAVA_HOME=/usr/local/jdk/jdk1.8.0_291 JRE_HOME=/usr/local/jdk/jdk1.8.0_291/jre |
Run linux命令 | 用于执行系统命令,同样可以执行多个,使用‘&&’表示命令分割。注意:每使用一次RUN命令,都会在叠加一层镜像,造成体积过大。因此尽量使用单个RUN命令,来执行多个linux命令避免镜像叠加。例如:RUN yum install wget && wget -O redis.tar.gz “http://download.redis.io/releases/redis-5.0.3.tar.gz” && tar -xvf redis.tar.gz |
ADD 宿主机文件或目录路径 容器路径 | 将宿主机的文件或目录拷贝到容器内,如果有压缩文件将会自动解压 |
COPY 宿主机文件或目录路径 容器路径 | 和ADD类似, 将宿主机的文件拷贝到容器内,但即使是存在压缩包文件也不会对其解压。 |
WORKDIR 目录路径 | 一:设置Dockerfile的工作目录,表示当前DockerFile执行的所有命令,都是在当前目录下所执行的,比如我使用’RUN wget www.ssol.cn/tools.sh’命令拉取一个文件,那么这个文件默认是保存在该目录下的。二:登陆容器伪终端后的所在目录,也将是这个目录。 |
该项目准确来说是一个爬虫小demo。
所使用的数据库为mysql.
所以我们大致明白,在基于这个centos7镜像的基础上,我们需要分别构建jdk1.8,mysql,nginx这三个。至于为什么不需要tomcat,是因为该项目是基于springboot的jar包方式打包,内部已经集成了tomcat。
(你也可以指定打包方式为war包来配合外部tomcat来部署,但我觉得麻烦,就直接用jar打包了。)
jdk使用的是:jdk-8u291-linux-x64.tar.gz
mysql使用的是:MySQL-5.6.22-1.el6.i686.rpm-bundle.tar
nginx使用的是:nginx-1.8.0.tar.gz
先使用rz,将jdk和mysql以及nginx上传到宿主机
(rz的使用:https://www.cnblogs.com/nbf-156cwl/p/8641165.html)
[root@ljy ~]# rz -y
[root@abc906093117 ~]# ll (查看是否上传到宿主机)
total 380188
-rw-r--r-- 1 root root 19384788 May 18 15:41 erlang-22.0.7-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 144935989 Jul 7 14:41 jdk-8u291-linux-x64.tar.gz
-rw-r--r-- 1 root root 213645065 Jul 12 01:34 MySQL-5.6.22-1.el6.i686.rpm-bundle.tar.gz
drwxr-xr-x 4 root root 4096 Jun 4 17:57 nacos
-rw-r--r-- 1 root root 832104 Mar 1 2020 nginx-1.8.0.tar.gz
-rw-r--r-- 1 root root 10494431 May 18 15:40 rabbitmq-server-3.7.18-1.el7.noarch.rpm
[root@abc906093117 ~]# mkdir -p /usr/local/dockerSpringBootProject (创建一个目录,该目录用于jdk相关的存放)
[root@abc906093117 ~]# mv jdk-8u291-linux-x64.tar.gz /usr/local/dockerSpringBootProject && mv MySQL-5.6.22-1.el6.i686.rpm-bundle.tar.gz /usr/local/dockerSpringBootProject && mv nginx-1.8.0.tar.gz /usr/local/dockerSpringBootProject (将上传了的jdk,nginx,mysql文件移动到该目录)
[root@abc906093117 ~]# cd /usr/local/dockerSpringBootProject (进入该目录)
[root@abc906093117 dockerjdk]# vi Dockerfile (创建dockerfile脚本文件,名称必须起名为‘Dockerfile',不然无法使用Dockerfile,注意首字母大写。)
Dockerfile脚本内容如下:
FROM centos:7 MAINTAINER lele WORKDIR /usr # 创建环境目录,并分别安装jdk,mysql和nginx得相关依赖库。 RUN mkdir /usr/local/jdk && mkdir /usr/local/mysql && mkdir /usr/local/nginx \ && yum update -y && yum install -y gcc-c++ && yum install -y glibc.i686 \ && yum install -y libaio.so.1 libgcc_s.so.1 libstdc++.so.6 && yum repolist -y && yum install -y libstdc++-4.8.5-44.el7.i686 \ && yum update -y libstdc++-4.8.5-44.el7.i686 && yum install -y libncurses.so.5 libtinfo.so.5 \ && yum install -y pcre pcre-devel && yum install -y zlib zlib-devel && yum install -y openssl openssl-devel # 将脚本文件所在目录下的jdk,mysql,nginx压缩包拷贝到容器,并自动解压 ADD jdk-8u291-linux-x64.tar.gz /usr/local/jdk ADD MySQL-5.6.22-1.el6.i686.rpm-bundle.tar.gz /usr/local/mysql ADD nginx-1.8.0.tar.gz /usr/local/mysql # 设置jdk环境变量 ENV JAVA_HOME=/usr/local/jdk/jdk1.8.0_291 JRE_HOME=$JAVA_HOME/jre CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib PATH=$JAVA_HOME/bin:$PATH
脚本编辑完毕后,按’:
'后输入wq
并按回车
进行保存.
此步骤的Dockerfile语法可以参考:
https://www.runoob.com/docker/docker-dockerfile.html
https://blog.csdn.net/weixin_39393393/article/details/116298849
https://blog.csdn.net/leon_wzm/article/details/78260795
https://blog.csdn.net/taiyangdao/article/details/73196424
构建命令格式为:
docker build -t 全为小写的自定义镜像名 .
例如:
docker build -t springbootproject .
其中’.
‘表示指定使用当前目录下的dockerfile脚本进行构建,当然,前提是当前目录下有一个名叫’Dockerfile’的脚本文件。
构建过程如下:
[root@abc906093117 dockerSpringBootProject]# docker build -t springbootproject . Sending build context to Docker daemon 359.4MB Step 1/8 : FROM centos:7 7: Pulling from library/centos Digest: sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e Status: Downloaded newer image for centos:7 ---> 8652b9f0cb4c Step 2/8 : MAINTAINER lele ---> Using cache ---> c7fdab0f66a5 Step 3/8 : WORKDIR /usr ---> Using cache ---> 87bbe938c8dc Step 4/8 : RUN mkdir /usr/local/jdk && mkdir /usr/local/mysql && mkdir /usr/local/nginx && yum update -y && yum install -y gcc-c++ && yum install -y glibc.i686 && yum install -y libaio.so.1 libgcc_s.so.1 libstdc++.so.6 && yum repolist -y && yum install -y libstdc++-4.8.5-44.el7.i686 && yum update -y libstdc++-4.8.5-44.el7.i686 && yum install -y libncurses.so.5 libtinfo.so.5 && yum install -y pcre pcre-devel && yum install -y zlib zlib-devel && yum install -y openssl openssl-devel ---> Running in 5d6353bac539 Loaded plugins: fastestmirror, ovl Determining fastest mirrors * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Resolving Dependencies --> Running transaction check ---> Package bind-license.noarch 32:9.11.4-26.P2.el7 will be updated ---> Package bind-license.noarch 32:9.11.4-26.P2.el7_9.5 will be an update ---> Package centos-release.x86_64 0:7-9.2009.0.el7.centos will be updated ---> Package centos-release.x86_64 0:7-9.2009.1.el7.centos will be an update ---> Package coreutils.x86_64 0:8.22-24.el7 will be updated ---> Package coreutils.x86_64 0:8.22-24.el7_9.2 will be an update ---> Package curl.x86_64 0:7.29.0-59.el7 will be updated ---> Package curl.x86_64 0:7.29.0-59.el7_9.1 will be an update ---> Package device-mapper.x86_64 7:1.02.170-6.el7 will be updated ---> Package device-mapper.x86_64 7:1.02.170-6.el7_9.5 will be an update ---> Package device-mapper-libs.x86_64 7:1.02.170-6.el7 will be updated ---> Package device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update ---> Package glib2.x86_64 0:2.56.1-7.el7 will be updated ---> Package glib2.x86_64 0:2.56.1-9.el7_9 will be an update ---> Package glibc.x86_64 0:2.17-317.el7 will be updated ---> Package glibc.x86_64 0:2.17-324.el7_9 will be an update ---> Package glibc-common.x86_64 0:2.17-317.el7 will be updated ---> Package glibc-common.x86_64 0:2.17-324.el7_9 will be an update ---> Package kpartx.x86_64 0:0.4.9-133.el7 will be updated ---> Package kpartx.x86_64 0:0.4.9-134.el7_9 will be an update ---> Package libblkid.x86_64 0:2.23.2-65.el7 will be updated ---> Package libblkid.x86_64 0:2.23.2-65.el7_9.1 will be an update ---> Package libcurl.x86_64 0:7.29.0-59.el7 will be updated ---> Package libcurl.x86_64 0:7.29.0-59.el7_9.1 will be an update ---> Package libmount.x86_64 0:2.23.2-65.el7 will be updated ---> Package libmount.x86_64 0:2.23.2-65.el7_9.1 will be an update ---> Package libsmartcols.x86_64 0:2.23.2-65.el7 will be updated ---> Package libsmartcols.x86_64 0:2.23.2-65.el7_9.1 will be an update ---> Package libuuid.x86_64 0:2.23.2-65.el7 will be updated ---> Package libuuid.x86_64 0:2.23.2-65.el7_9.1 will be an update ---> Package nss.x86_64 0:3.53.1-3.el7_9 will be updated ---> Package nss.x86_64 0:3.53.1-7.el7_9 will be an update ---> Package nss-sysinit.x86_64 0:3.53.1-3.el7_9 will be updated ---> Package nss-sysinit.x86_64 0:3.53.1-7.el7_9 will be an update ---> Package nss-tools.x86_64 0:3.53.1-3.el7_9 will be updated ---> Package nss-tools.x86_64 0:3.53.1-7.el7_9 will be an update ---> Package openldap.x86_64 0:2.4.44-22.el7 will be updated ---> Package openldap.x86_64 0:2.4.44-23.el7_9 will be an update ---> Package openssl-libs.x86_64 1:1.0.2k-19.el7 will be updated ---> Package openssl-libs.x86_64 1:1.0.2k-21.el7_9 will be an update ---> Package python.x86_64 0:2.7.5-89.el7 will be updated ---> Package python.x86_64 0:2.7.5-90.el7 will be an update ---> Package python-libs.x86_64 0:2.7.5-89.el7 will be updated ---> Package python-libs.x86_64 0:2.7.5-90.el7 will be an update ---> Package systemd.x86_64 0:219-78.el7 will be updated ---> Package systemd.x86_64 0:219-78.el7_9.3 will be an update ---> Package systemd-libs.x86_64 0:219-78.el7 will be updated ---> Package systemd-libs.x86_64 0:219-78.el7_9.3 will be an update ---> Package tzdata.noarch 0:2020d-2.el7 will be updated ---> Package tzdata.noarch 0:2021a-1.el7 will be an update ---> Package util-linux.x86_64 0:2.23.2-65.el7 will be updated ---> Package util-linux.x86_64 0:2.23.2-65.el7_9.1 will be an update ---> Package vim-minimal.x86_64 2:7.4.629-7.el7 will be updated ---> Package vim-minimal.x86_64 2:7.4.629-8.el7_9 will be an update ---> Package zlib.x86_64 0:1.2.7-18.el7 will be updated ---> Package zlib.x86_64 0:1.2.7-19.el7_9 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Updating: bind-license noarch 32:9.11.4-26.P2.el7_9.5 updates 91 k centos-release x86_64 7-9.2009.1.el7.centos updates 27 k coreutils x86_64 8.22-24.el7_9.2 updates 3.3 M curl x86_64 7.29.0-59.el7_9.1 updates 271 k device-mapper x86_64 7:1.02.170-6.el7_9.5 updates 297 k device-mapper-libs x86_64 7:1.02.170-6.el7_9.5 updates 325 k glib2 x86_64 2.56.1-9.el7_9 updates 2.5 M glibc x86_64 2.17-324.el7_9 updates 3.6 M glibc-common x86_64 2.17-324.el7_9 updates 12 M kpartx x86_64 0.4.9-134.el7_9 updates 81 k libblkid x86_64 2.23.2-65.el7_9.1 updates 183 k libcurl x86_64 7.29.0-59.el7_9.1 updates 223 k libmount x86_64 2.23.2-65.el7_9.1 updates 185 k libsmartcols x86_64 2.23.2-65.el7_9.1 updates 143 k libuuid x86_64 2.23.2-65.el7_9.1 updates 84 k nss x86_64 3.53.1-7.el7_9 updates 869 k nss-sysinit x86_64 3.53.1-7.el7_9 updates 66 k nss-tools x86_64 3.53.1-7.el7_9 updates 535 k openldap x86_64 2.4.44-23.el7_9 updates 356 k openssl-libs x86_64 1:1.0.2k-21.el7_9 updates 1.2 M python x86_64 2.7.5-90.el7 updates 96 k python-libs x86_64 2.7.5-90.el7 updates 5.6 M systemd x86_64 219-78.el7_9.3 updates 5.1 M systemd-libs x86_64 219-78.el7_9.3 updates 418 k tzdata noarch 2021a-1.el7 updates 501 k util-linux x86_64 2.23.2-65.el7_9.1 updates 2.0 M vim-minimal x86_64 2:7.4.629-8.el7_9 updates 443 k zlib x86_64 1.2.7-19.el7_9 updates 90 k Transaction Summary ================================================================================ Upgrade 28 Packages Total download size: 40 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. Public key for centos-release-7-9.2009.1.el7.centos.x86_64.rpm is not installed warning: /var/cache/yum/x86_64/7/updates/packages/centos-release-7-9.2009.1.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY -------------------------------------------------------------------------------- Total 16 MB/s | 40 MB 00:02 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-9.2009.0.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 Updating : tzdata-2021a-1.el7.noarch 1/56 Updating : glibc-2.17-324.el7_9.x86_64 2/56 Updating : glibc-common-2.17-324.el7_9.x86_64 3/56 Updating : zlib-1.2.7-19.el7_9.x86_64 4/56 Updating : 1:openssl-libs-1.0.2k-21.el7_9.x86_64 5/56 Updating : coreutils-8.22-24.el7_9.2.x86_64 6/56 Updating : systemd-libs-219-78.el7_9.3.x86_64 7/56 Updating : libuuid-2.23.2-65.el7_9.1.x86_64 8/56 Updating : libblkid-2.23.2-65.el7_9.1.x86_64 9/56 Updating : libmount-2.23.2-65.el7_9.1.x86_64 10/56 Updating : nss-3.53.1-7.el7_9.x86_64 11/56 Updating : nss-sysinit-3.53.1-7.el7_9.x86_64 12/56 Updating : nss-tools-3.53.1-7.el7_9.x86_64 13/56 Updating : openldap-2.4.44-23.el7_9.x86_64 14/56 Updating : libcurl-7.29.0-59.el7_9.1.x86_64 15/56 Updating : python-libs-2.7.5-90.el7.x86_64 16/56 Updating : libsmartcols-2.23.2-65.el7_9.1.x86_64 17/56 Updating : util-linux-2.23.2-65.el7_9.1.x86_64 18/56 Updating : centos-release-7-9.2009.1.el7.centos.x86_64 19/56 Updating : systemd-219-78.el7_9.3.x86_64 20/56 Failed to get D-Bus connection: Operation not permitted Updating : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64 21/56 Updating : 7:device-mapper-1.02.170-6.el7_9.5.x86_64 22/56 Updating : kpartx-0.4.9-134.el7_9.x86_64 23/56 Updating : python-2.7.5-90.el7.x86_64 24/56 Updating : curl-7.29.0-59.el7_9.1.x86_64 25/56 Updating : glib2-2.56.1-9.el7_9.x86_64 26/56 Updating : 2:vim-minimal-7.4.629-8.el7_9.x86_64 27/56 Updating : 32:bind-license-9.11.4-26.P2.el7_9.5.noarch 28/56 Cleanup : curl-7.29.0-59.el7.x86_64 29/56 Cleanup : glib2-2.56.1-7.el7.x86_64 30/56 Cleanup : python-2.7.5-89.el7.x86_64 31/56 Cleanup : 32:bind-license-9.11.4-26.P2.el7.noarch 32/56 Cleanup : python-libs-2.7.5-89.el7.x86_64 33/56 Cleanup : kpartx-0.4.9-133.el7.x86_64 34/56 Cleanup : 7:device-mapper-1.02.170-6.el7.x86_64 35/56 Cleanup : 7:device-mapper-libs-1.02.170-6.el7.x86_64 36/56 Cleanup : systemd-219-78.el7.x86_64 37/56 Cleanup : util-linux-2.23.2-65.el7.x86_64 38/56 Cleanup : libcurl-7.29.0-59.el7.x86_64 39/56 Cleanup : openldap-2.4.44-22.el7.x86_64 40/56 Cleanup : nss-tools-3.53.1-3.el7_9.x86_64 41/56 Cleanup : libmount-2.23.2-65.el7.x86_64 42/56 Cleanup : libblkid-2.23.2-65.el7.x86_64 43/56 Cleanup : nss-sysinit-3.53.1-3.el7_9.x86_64 44/56 Cleanup : nss-3.53.1-3.el7_9.x86_64 45/56 Cleanup : coreutils-8.22-24.el7.x86_64 46/56 Cleanup : 1:openssl-libs-1.0.2k-19.el7.x86_64 47/56 Cleanup : zlib-1.2.7-18.el7.x86_64 48/56 Cleanup : libuuid-2.23.2-65.el7.x86_64 49/56 Cleanup : libsmartcols-2.23.2-65.el7.x86_64 50/56 Cleanup : systemd-libs-219-78.el7.x86_64 51/56 Cleanup : 2:vim-minimal-7.4.629-7.el7.x86_64 52/56 Cleanup : centos-release-7-9.2009.0.el7.centos.x86_64 53/56 Cleanup : glibc-common-2.17-317.el7.x86_64 54/56 Cleanup : glibc-2.17-317.el7.x86_64 55/56 Cleanup : tzdata-2020d-2.el7.noarch 56/56 Verifying : python-2.7.5-90.el7.x86_64 1/56 Verifying : 32:bind-license-9.11.4-26.P2.el7_9.5.noarch 2/56 Verifying : systemd-libs-219-78.el7_9.3.x86_64 3/56 Verifying : libmount-2.23.2-65.el7_9.1.x86_64 4/56 Verifying : zlib-1.2.7-19.el7_9.x86_64 5/56 Verifying : glib2-2.56.1-9.el7_9.x86_64 6/56 Verifying : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64 7/56 Verifying : glibc-common-2.17-324.el7_9.x86_64 8/56 Verifying : centos-release-7-9.2009.1.el7.centos.x86_64 9/56 Verifying : systemd-219-78.el7_9.3.x86_64 10/56 Verifying : libsmartcols-2.23.2-65.el7_9.1.x86_64 11/56 Verifying : nss-sysinit-3.53.1-7.el7_9.x86_64 12/56 Verifying : openldap-2.4.44-23.el7_9.x86_64 13/56 Verifying : libblkid-2.23.2-65.el7_9.1.x86_64 14/56 Verifying : coreutils-8.22-24.el7_9.2.x86_64 15/56 Verifying : kpartx-0.4.9-134.el7_9.x86_64 16/56 Verifying : libcurl-7.29.0-59.el7_9.1.x86_64 17/56 Verifying : 1:openssl-libs-1.0.2k-21.el7_9.x86_64 18/56 Verifying : util-linux-2.23.2-65.el7_9.1.x86_64 19/56 Verifying : curl-7.29.0-59.el7_9.1.x86_64 20/56 Verifying : python-libs-2.7.5-90.el7.x86_64 21/56 Verifying : glibc-2.17-324.el7_9.x86_64 22/56 Verifying : 2:vim-minimal-7.4.629-8.el7_9.x86_64 23/56 Verifying : libuuid-2.23.2-65.el7_9.1.x86_64 24/56 Verifying : 7:device-mapper-1.02.170-6.el7_9.5.x86_64 25/56 Verifying : nss-3.53.1-7.el7_9.x86_64 26/56 Verifying : tzdata-2021a-1.el7.noarch 27/56 Verifying : nss-tools-3.53.1-7.el7_9.x86_64 28/56 Verifying : libuuid-2.23.2-65.el7.x86_64 29/56 Verifying : 2:vim-minimal-7.4.629-7.el7.x86_64 30/56 Verifying : glibc-2.17-317.el7.x86_64 31/56 Verifying : nss-tools-3.53.1-3.el7_9.x86_64 32/56 Verifying : glibc-common-2.17-317.el7.x86_64 33/56 Verifying : coreutils-8.22-24.el7.x86_64 34/56 Verifying : nss-3.53.1-3.el7_9.x86_64 35/56 Verifying : zlib-1.2.7-18.el7.x86_64 36/56 Verifying : systemd-libs-219-78.el7.x86_64 37/56 Verifying : glib2-2.56.1-7.el7.x86_64 38/56 Verifying : 1:openssl-libs-1.0.2k-19.el7.x86_64 39/56 Verifying : kpartx-0.4.9-133.el7.x86_64 40/56 Verifying : centos-release-7-9.2009.0.el7.centos.x86_64 41/56 Verifying : nss-sysinit-3.53.1-3.el7_9.x86_64 42/56 Verifying : python-libs-2.7.5-89.el7.x86_64 43/56 Verifying : 7:device-mapper-1.02.170-6.el7.x86_64 44/56 Verifying : openldap-2.4.44-22.el7.x86_64 45/56 Verifying : 7:device-mapper-libs-1.02.170-6.el7.x86_64 46/56 Verifying : libblkid-2.23.2-65.el7.x86_64 47/56 Verifying : systemd-219-78.el7.x86_64 48/56 Verifying : util-linux-2.23.2-65.el7.x86_64 49/56 Verifying : python-2.7.5-89.el7.x86_64 50/56 Verifying : libcurl-7.29.0-59.el7.x86_64 51/56 Verifying : curl-7.29.0-59.el7.x86_64 52/56 Verifying : tzdata-2020d-2.el7.noarch 53/56 Verifying : libsmartcols-2.23.2-65.el7.x86_64 54/56 Verifying : libmount-2.23.2-65.el7.x86_64 55/56 Verifying : 32:bind-license-9.11.4-26.P2.el7.noarch 56/56 Updated: bind-license.noarch 32:9.11.4-26.P2.el7_9.5 centos-release.x86_64 0:7-9.2009.1.el7.centos coreutils.x86_64 0:8.22-24.el7_9.2 curl.x86_64 0:7.29.0-59.el7_9.1 device-mapper.x86_64 7:1.02.170-6.el7_9.5 device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 glib2.x86_64 0:2.56.1-9.el7_9 glibc.x86_64 0:2.17-324.el7_9 glibc-common.x86_64 0:2.17-324.el7_9 kpartx.x86_64 0:0.4.9-134.el7_9 libblkid.x86_64 0:2.23.2-65.el7_9.1 libcurl.x86_64 0:7.29.0-59.el7_9.1 libmount.x86_64 0:2.23.2-65.el7_9.1 libsmartcols.x86_64 0:2.23.2-65.el7_9.1 libuuid.x86_64 0:2.23.2-65.el7_9.1 nss.x86_64 0:3.53.1-7.el7_9 nss-sysinit.x86_64 0:3.53.1-7.el7_9 nss-tools.x86_64 0:3.53.1-7.el7_9 openldap.x86_64 0:2.4.44-23.el7_9 openssl-libs.x86_64 1:1.0.2k-21.el7_9 python.x86_64 0:2.7.5-90.el7 python-libs.x86_64 0:2.7.5-90.el7 systemd.x86_64 0:219-78.el7_9.3 systemd-libs.x86_64 0:219-78.el7_9.3 tzdata.noarch 0:2021a-1.el7 util-linux.x86_64 0:2.23.2-65.el7_9.1 vim-minimal.x86_64 2:7.4.629-8.el7_9 zlib.x86_64 0:1.2.7-19.el7_9 Complete! Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Resolving Dependencies --> Running transaction check ---> Package gcc-c++.x86_64 0:4.8.5-44.el7 will be installed --> Processing Dependency: libstdc++-devel = 4.8.5-44.el7 for package: gcc-c++-4.8.5-44.el7.x86_64 --> Processing Dependency: gcc = 4.8.5-44.el7 for package: gcc-c++-4.8.5-44.el7.x86_64 --> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-c++-4.8.5-44.el7.x86_64 --> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-c++-4.8.5-44.el7.x86_64 --> Running transaction check ---> Package gcc.x86_64 0:4.8.5-44.el7 will be installed --> Processing Dependency: libgomp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64 --> Processing Dependency: cpp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64 --> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-44.el7.x86_64 --> Processing Dependency: libgomp.so.1()(64bit) for package: gcc-4.8.5-44.el7.x86_64 ---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed ---> Package libstdc++-devel.x86_64 0:4.8.5-44.el7 will be installed ---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed --> Running transaction check ---> Package cpp.x86_64 0:4.8.5-44.el7 will be installed ---> Package glibc-devel.x86_64 0:2.17-324.el7_9 will be installed --> Processing Dependency: glibc-headers = 2.17-324.el7_9 for package: glibc-devel-2.17-324.el7_9.x86_64 --> Processing Dependency: glibc-headers for package: glibc-devel-2.17-324.el7_9.x86_64 ---> Package libgomp.x86_64 0:4.8.5-44.el7 will be installed --> Running transaction check ---> Package glibc-headers.x86_64 0:2.17-324.el7_9 will be installed --> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-324.el7_9.x86_64 --> Processing Dependency: kernel-headers for package: glibc-headers-2.17-324.el7_9.x86_64 --> Running transaction check ---> Package kernel-headers.x86_64 0:3.10.0-1160.31.1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: gcc-c++ x86_64 4.8.5-44.el7 base 7.2 M Installing for dependencies: cpp x86_64 4.8.5-44.el7 base 5.9 M gcc x86_64 4.8.5-44.el7 base 16 M glibc-devel x86_64 2.17-324.el7_9 updates 1.1 M glibc-headers x86_64 2.17-324.el7_9 updates 691 k kernel-headers x86_64 3.10.0-1160.31.1.el7 updates 9.0 M libgomp x86_64 4.8.5-44.el7 base 159 k libmpc x86_64 1.0.1-3.el7 base 51 k libstdc++-devel x86_64 4.8.5-44.el7 base 1.5 M mpfr x86_64 3.1.1-4.el7 base 203 k Transaction Summary ================================================================================ Install 1 Package (+9 Dependent packages) Total download size: 42 M Installed size: 85 M Downloading packages: -------------------------------------------------------------------------------- Total 2.0 MB/s | 42 MB 00:20 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mpfr-3.1.1-4.el7.x86_64 1/10 Installing : libmpc-1.0.1-3.el7.x86_64 2/10 Installing : cpp-4.8.5-44.el7.x86_64 3/10 Installing : kernel-headers-3.10.0-1160.31.1.el7.x86_64 4/10 Installing : glibc-headers-2.17-324.el7_9.x86_64 5/10 Installing : glibc-devel-2.17-324.el7_9.x86_64 6/10 Installing : libgomp-4.8.5-44.el7.x86_64 7/10 Installing : gcc-4.8.5-44.el7.x86_64 8/10 Installing : libstdc++-devel-4.8.5-44.el7.x86_64 9/10 Installing : gcc-c++-4.8.5-44.el7.x86_64 10/10 Verifying : gcc-c++-4.8.5-44.el7.x86_64 1/10 Verifying : mpfr-3.1.1-4.el7.x86_64 2/10 Verifying : glibc-headers-2.17-324.el7_9.x86_64 3/10 Verifying : cpp-4.8.5-44.el7.x86_64 4/10 Verifying : glibc-devel-2.17-324.el7_9.x86_64 5/10 Verifying : gcc-4.8.5-44.el7.x86_64 6/10 Verifying : libstdc++-devel-4.8.5-44.el7.x86_64 7/10 Verifying : libmpc-1.0.1-3.el7.x86_64 8/10 Verifying : libgomp-4.8.5-44.el7.x86_64 9/10 Verifying : kernel-headers-3.10.0-1160.31.1.el7.x86_64 10/10 Installed: gcc-c++.x86_64 0:4.8.5-44.el7 Dependency Installed: cpp.x86_64 0:4.8.5-44.el7 gcc.x86_64 0:4.8.5-44.el7 glibc-devel.x86_64 0:2.17-324.el7_9 glibc-headers.x86_64 0:2.17-324.el7_9 kernel-headers.x86_64 0:3.10.0-1160.31.1.el7 libgomp.x86_64 0:4.8.5-44.el7 libmpc.x86_64 0:1.0.1-3.el7 libstdc++-devel.x86_64 0:4.8.5-44.el7 mpfr.x86_64 0:3.1.1-4.el7 Complete! Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Resolving Dependencies --> Running transaction check ---> Package glibc.i686 0:2.17-324.el7_9 will be installed --> Processing Dependency: libfreebl3.so(NSSRAWHASH_3.12.3) for package: glibc-2.17-324.el7_9.i686 --> Processing Dependency: libfreebl3.so for package: glibc-2.17-324.el7_9.i686 --> Running transaction check ---> Package nss-softokn-freebl.i686 0:3.53.1-6.el7_9 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: glibc i686 2.17-324.el7_9 updates 4.3 M Installing for dependencies: nss-softokn-freebl i686 3.53.1-6.el7_9 updates 322 k Transaction Summary ================================================================================ Install 1 Package (+1 Dependent package) Total download size: 4.6 M Installed size: 15 M Downloading packages: -------------------------------------------------------------------------------- Total 15 MB/s | 4.6 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : nss-softokn-freebl-3.53.1-6.el7_9.i686 1/2 Installing : glibc-2.17-324.el7_9.i686 2/2 Verifying : glibc-2.17-324.el7_9.i686 1/2 Verifying : nss-softokn-freebl-3.53.1-6.el7_9.i686 2/2 Installed: glibc.i686 0:2.17-324.el7_9 Dependency Installed: nss-softokn-freebl.i686 0:3.53.1-6.el7_9 Complete! Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Resolving Dependencies --> Running transaction check ---> Package libaio.i686 0:0.3.109-13.el7 will be installed ---> Package libgcc.i686 0:4.8.5-44.el7 will be installed ---> Package libstdc++.i686 0:4.8.5-44.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: libaio i686 0.3.109-13.el7 base 24 k libgcc i686 4.8.5-44.el7 base 111 k libstdc++ i686 4.8.5-44.el7 base 319 k Transaction Summary ================================================================================ Install 3 Packages Total download size: 454 k Installed size: 1.2 M Downloading packages: -------------------------------------------------------------------------------- Total 1.7 MB/s | 454 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libgcc-4.8.5-44.el7.i686 1/3 Installing : libstdc++-4.8.5-44.el7.i686 2/3 Installing : libaio-0.3.109-13.el7.i686 3/3 Verifying : libstdc++-4.8.5-44.el7.i686 1/3 Verifying : libaio-0.3.109-13.el7.i686 2/3 Verifying : libgcc-4.8.5-44.el7.i686 3/3 Installed: libaio.i686 0:0.3.109-13.el7 libgcc.i686 0:4.8.5-44.el7 libstdc++.i686 0:4.8.5-44.el7 Complete! Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com repo id repo name status base/7/x86_64 CentOS-7 - Base 10072 extras/7/x86_64 CentOS-7 - Extras 498 updates/7/x86_64 CentOS-7 - Updates 2461 repolist: 13031 Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Package libstdc++-4.8.5-44.el7.i686 already installed and latest version Nothing to do Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com No packages marked for update Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Resolving Dependencies --> Running transaction check ---> Package ncurses-libs.i686 0:5.9-14.20130511.el7_4 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: ncurses-libs i686 5.9-14.20130511.el7_4 base 316 k Transaction Summary ================================================================================ Install 1 Package Total download size: 316 k Installed size: 926 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : ncurses-libs-5.9-14.20130511.el7_4.i686 1/1 Verifying : ncurses-libs-5.9-14.20130511.el7_4.i686 1/1 Installed: ncurses-libs.i686 0:5.9-14.20130511.el7_4 Complete! Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Package pcre-8.32-17.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: pcre-devel x86_64 8.32-17.el7 base 480 k Transaction Summary ================================================================================ Install 1 Package Total download size: 480 k Installed size: 1.4 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pcre-devel-8.32-17.el7.x86_64 1/1 Verifying : pcre-devel-8.32-17.el7.x86_64 1/1 Installed: pcre-devel.x86_64 0:8.32-17.el7 Complete! Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Package zlib-1.2.7-19.el7_9.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package zlib-devel.x86_64 0:1.2.7-19.el7_9 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: zlib-devel x86_64 1.2.7-19.el7_9 updates 50 k Transaction Summary ================================================================================ Install 1 Package Total download size: 50 k Installed size: 132 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : zlib-devel-1.2.7-19.el7_9.x86_64 1/1 Verifying : zlib-devel-1.2.7-19.el7_9.x86_64 1/1 Installed: zlib-devel.x86_64 0:1.2.7-19.el7_9 Complete! Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Resolving Dependencies --> Running transaction check ---> Package openssl.x86_64 1:1.0.2k-21.el7_9 will be installed --> Processing Dependency: make for package: 1:openssl-1.0.2k-21.el7_9.x86_64 ---> Package openssl-devel.x86_64 1:1.0.2k-21.el7_9 will be installed --> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-21.el7_9.x86_64 --> Running transaction check ---> Package krb5-devel.x86_64 0:1.15.1-50.el7 will be installed --> Processing Dependency: libkadm5(x86-64) = 1.15.1-50.el7 for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-50.el7.x86_64 ---> Package make.x86_64 1:3.82-24.el7 will be installed --> Running transaction check ---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed ---> Package libcom_err-devel.x86_64 0:1.42.9-19.el7 will be installed ---> Package libkadm5.x86_64 0:1.15.1-50.el7 will be installed ---> Package libselinux-devel.x86_64 0:2.5-15.el7 will be installed --> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-15.el7.x86_64 --> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-15.el7.x86_64 ---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed --> Running transaction check ---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: openssl x86_64 1:1.0.2k-21.el7_9 updates 493 k openssl-devel x86_64 1:1.0.2k-21.el7_9 updates 1.5 M Installing for dependencies: keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k krb5-devel x86_64 1.15.1-50.el7 base 273 k libcom_err-devel x86_64 1.42.9-19.el7 base 32 k libkadm5 x86_64 1.15.1-50.el7 base 179 k libselinux-devel x86_64 2.5-15.el7 base 187 k libsepol-devel x86_64 2.5-10.el7 base 77 k libverto-devel x86_64 0.2.5-4.el7 base 12 k make x86_64 1:3.82-24.el7 base 421 k Transaction Summary ================================================================================ Install 2 Packages (+8 Dependent packages) Total download size: 3.2 M Installed size: 6.4 M Downloading packages: -------------------------------------------------------------------------------- Total 5.3 MB/s | 3.2 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libkadm5-1.15.1-50.el7.x86_64 1/10 Installing : libsepol-devel-2.5-10.el7.x86_64 2/10 Installing : libselinux-devel-2.5-15.el7.x86_64 3/10 Installing : 1:make-3.82-24.el7.x86_64 4/10 Installing : libcom_err-devel-1.42.9-19.el7.x86_64 5/10 Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64 6/10 Installing : libverto-devel-0.2.5-4.el7.x86_64 7/10 Installing : krb5-devel-1.15.1-50.el7.x86_64 8/10 Installing : 1:openssl-devel-1.0.2k-21.el7_9.x86_64 9/10 Installing : 1:openssl-1.0.2k-21.el7_9.x86_64 10/10 Verifying : libselinux-devel-2.5-15.el7.x86_64 1/10 Verifying : 1:openssl-devel-1.0.2k-21.el7_9.x86_64 2/10 Verifying : libverto-devel-0.2.5-4.el7.x86_64 3/10 Verifying : krb5-devel-1.15.1-50.el7.x86_64 4/10 Verifying : keyutils-libs-devel-1.5.8-3.el7.x86_64 5/10 Verifying : libcom_err-devel-1.42.9-19.el7.x86_64 6/10 Verifying : 1:make-3.82-24.el7.x86_64 7/10 Verifying : 1:openssl-1.0.2k-21.el7_9.x86_64 8/10 Verifying : libsepol-devel-2.5-10.el7.x86_64 9/10 Verifying : libkadm5-1.15.1-50.el7.x86_64 10/10 Installed: openssl.x86_64 1:1.0.2k-21.el7_9 openssl-devel.x86_64 1:1.0.2k-21.el7_9 Dependency Installed: keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-50.el7 libcom_err-devel.x86_64 0:1.42.9-19.el7 libkadm5.x86_64 0:1.15.1-50.el7 libselinux-devel.x86_64 0:2.5-15.el7 libsepol-devel.x86_64 0:2.5-10.el7 libverto-devel.x86_64 0:0.2.5-4.el7 make.x86_64 1:3.82-24.el7 Complete! Removing intermediate container 5d6353bac539 ---> 3183a1c28b8e Step 5/8 : ADD jdk-8u291-linux-x64.tar.gz /usr/local/jdk ---> 9b4f46d6a54c Step 6/8 : ADD MySQL-5.6.22-1.el6.i686.rpm-bundle.tar.gz /usr/local/mysql ---> e85b33d11026 Step 7/8 : ADD nginx-1.8.0.tar.gz /usr/local/mysql ---> 25d59f129cab Step 8/8 : ENV JAVA_HOME=/usr/local/jdk/jdk1.8.0_291 JRE_HOME=$JAVA_HOME/jre CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib PATH=$JAVA_HOME/bin:$PATH ---> Running in 6d603456df34 Removing intermediate container 6d603456df34 ---> 7846c4b9c3c6 Successfully built 7846c4b9c3c6 Successfully tagged springbootproject:latest
注意:
如果你用到了Dockerfile的Run命令语法来执行的多个或单个linux命令的话,需要保证每个linux命令在执行时都不会出错;否则Dockerfile构建镜像会失败,失败后触发事务,不存在这个镜像。
如下错误:
应该是找不着那个mysql需要的依赖包
No package libstdc++-4.8.5-39.el7.i686 available.
Error: Nothing to do
The command '/bin/sh -c mkdir /usr/local/jdk && mkdir /usr/local/mysql && mkdir /usr/local/nginx && yum update -y && yum install -y gcc-c++ && yum install -y glibc.i686 && yum install -y libaio.so.1 libgcc_s.so.1 libstdc++.so.6 && yum repolist -y && yum install -y libstdc++-4.8.5-39.el7.i686 && yum update -y libstdc++-4.8.5-39.el7.i686 && yum install -y libncurses.so.5 libtinfo.so.5 && yum install -y pcre pcre-devel && yum install -y zlib zlib-devel && yum install -y openssl openssl-devel' returned a non-zero code: 1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。