正在学习Docker相关的部署,基于此记录在华为云ECS上安装部署Docker的过程和问题,为自己今后查阅留痕。
查看ECS服务器操作系统版本是否支持Docker,命令行输入uname -r
查看内核版本,返回的值大于3.10即可。
[root@ecs-s6 ~]# uname -r
3.10.0-1062.1.1.el7.x86_64
[root@ecs-s6 ~]#
本人直接使用最简单的yum命令进行安装:yum -y install docker
安装过程输出日志如下
[root@ecs-s6 ~]#
[root@ecs-s6 ~]# yum -y install docker
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink | 7.9 kB 00:00:00
* base: mirrors.cn99.com
* epel: mirrors.yun-idc.com
* extras: mirrors.nju.edu.cn
* updates: mirrors.cn99.com
base | 3.6 kB 00:00:00
epel | 5.3 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/5): extras/7/x86_64/primary_db | 153 kB 00:00:00
(2/5): epel/x86_64/group_gz | 90 kB 00:00:00
(3/5): updates/7/x86_64/primary_db | 5.8 MB 00:00:01
(4/5): epel/x86_64/updateinfo | 1.0 MB 00:00:02
epel/x86_64/primary_db FAILED
http://mirror.pregi.net/pub/Linux/Fedora/epel/7/x86_64/repodata/b4cb89fa1965c9a079897af3ec59868789b351f89650effa3495355536107fe4-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
(5/5): epel/x86_64/primary_db | 6.9 MB 00:00:03
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 2:1.13.1-103.git7f2769b.el7.centos will be installed
--> Processing Dependency: docker-common = 2:1.13.1-103.git7f2769b.el7.centos for package: 2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: docker-client = 2:1.13.1-103.git7f2769b.el7.centos for package: 2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: subscription-manager-rhsm-certificates for package: 2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package: 2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Running transaction check
---> Package docker-client.x86_64 2:1.13.1-103.git7f2769b.el7.centos will be installed
---> Package docker-common.x86_64 2:1.13.1-103.git7f2769b.el7.centos will be installed
--> Processing Dependency: skopeo-containers >= 1:0.1.26-2 for package: 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: oci-umount >= 2:2.3.3-3 for package: 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: oci-systemd-hook >= 1:0.1.4-9 for package: 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: oci-register-machine >= 1:0-5.13 for package: 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: lvm2 >= 2.02.112 for package: 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: container-storage-setup >= 0.9.0-1 for package: 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: container-selinux >= 2:2.51-1 for package: 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: atomic-registries for package: 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64
---> Package libseccomp.x86_64 0:2.3.1-3.el7 will be installed
---> Package subscription-manager-rhsm-certificates.x86_64 0:1.24.13-3.el7.centos will be installed
--> Running transaction check
---> Package atomic-registries.x86_64 1:1.22.1-29.gitb507039.el7 will be installed
--> Processing Dependency: python-yaml for package: 1:atomic-registries-1.22.1-29.gitb507039.el7.x86_64
--> Processing Dependency: python-setuptools for package: 1:atomic-registries-1.22.1-29.gitb507039.el7.x86_64
--> Processing Dependency: python-pytoml for package: 1:atomic-registries-1.22.1-29.gitb507039.el7.x86_64
---> Package container-selinux.noarch 2:2.107-3.el7 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.107-3.el7.noarch
---> Package container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7 will be installed
---> Package containers-common.x86_64 1:0.1.37-3.el7.centos will be installed
---> Package lvm2.x86_64 7:2.02.185-2.el7_7.2 will be installed
--> Processing Dependency: lvm2-libs = 7:2.02.185-2.el7_7.2 for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
--> Processing Dependency: device-mapper-persistent-data >= 0.7.0-0.1.rc6 for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
--> Processing Dependency: liblvm2app.so.2.2(Base)(64bit) for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
--> Processing Dependency: libdevmapper-event.so.1.02(Base)(64bit) for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
--> Processing Dependency: liblvm2app.so.2.2()(64bit) for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
--> Processing Dependency: libdevmapper-event.so.1.02()(64bit) for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
---> Package oci-register-machine.x86_64 1:0-6.git2b44233.el7 will be installed
---> Package oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6 will be installed
--> Processing Dependency: libyajl.so.2()(64bit) for package: 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64
---> Package oci-umount.x86_64 2:2.5-3.el7 will be installed
--> Running transaction check
---> Package PyYAML.x86_64 0:3.10-11.el7 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: PyYAML-3.10-11.el7.x86_64
---> Package device-mapper-event-libs.x86_64 7:1.02.158-2.el7_7.2 will be installed
---> Package device-mapper-persistent-data.x86_64 0:0.8.5-1.el7 will be installed
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package lvm2-libs.x86_64 7:2.02.185-2.el7_7.2 will be installed
--> Processing Dependency: device-mapper-event = 7:1.02.158-2.el7_7.2 for package: 7:lvm2-libs-2.02.185-2.el7_7.2.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-33.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
---> Package python-pytoml.noarch 0:0.1.14-1.git7dea353.el7 will be installed
---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch
---> Package yajl.x86_64 0:2.0.4-4.el7 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 device-mapper-event.x86_64 7:1.02.158-2.el7_7.2 will be installed
--> Processing Dependency: device-mapper = 7:1.02.158-2.el7_7.2 for package: 7:device-mapper-event-1.02.158-2.el7_7.2.x86_64
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package libyaml.x86_64 0:0.1.4-11.el7_0 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed
--> Processing Dependency: python-ipaddress for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.158-2.el7 will be updated
--> Processing Dependency: device-mapper = 7:1.02.158-2.el7 for package: 7:device-mapper-libs-1.02.158-2.el7.x86_64
---> Package device-mapper.x86_64 7:1.02.158-2.el7_7.2 will be an update
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed
--> Running transaction check
---> Package device-mapper-libs.x86_64 7:1.02.158-2.el7 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.158-2.el7_7.2 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================
Installing:
docker x86_64 2:1.13.1-103.git7f2769b.el7.centos extras 18 M
Installing for dependencies:
PyYAML x86_64 3.10-11.el7 base 153 k
atomic-registries x86_64 1:1.22.1-29.gitb507039.el7 extras 35 k
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.107-3.el7 extras 39 k
container-storage-setup noarch 0.11.0-2.git5eaf76c.el7 extras 35 k
containers-common x86_64 1:0.1.37-3.el7.centos extras 21 k
device-mapper-event x86_64 7:1.02.158-2.el7_7.2 updates 190 k
device-mapper-event-libs x86_64 7:1.02.158-2.el7_7.2 updates 189 k
device-mapper-persistent-data x86_64 0.8.5-1.el7 base 423 k
docker-client x86_64 2:1.13.1-103.git7f2769b.el7.centos extras 3.9 M
docker-common x86_64 2:1.13.1-103.git7f2769b.el7.centos extras 97 k
libaio x86_64 0.3.109-13.el7 base 24 k
libcgroup x86_64 0.41-21.el7 base 66 k
libseccomp x86_64 2.3.1-3.el7 base 56 k
libsemanage-python x86_64 2.5-14.el7 base 113 k
libyaml x86_64 0.1.4-11.el7_0 base 55 k
lvm2 x86_64 7:2.02.185-2.el7_7.2 updates 1.3 M
lvm2-libs x86_64 7:2.02.185-2.el7_7.2 updates 1.1 M
oci-register-machine x86_64 1:0-6.git2b44233.el7 extras 1.1 M
oci-systemd-hook x86_64 1:0.2.0-1.git05e6923.el7_6 extras 34 k
oci-umount x86_64 2:2.5-3.el7 extras 33 k
policycoreutils-python x86_64 2.5-33.el7 base 457 k
python-IPy noarch 0.75-6.el7 base 32 k
python-backports x86_64 1.0-8.el7 base 5.8 k
python-backports-ssl_match_hostname noarch 3.5.0.1-1.el7 base 13 k
python-ipaddress noarch 1.0.16-2.el7 base 34 k
python-pytoml noarch 0.1.14-1.git7dea353.el7 extras 18 k
python-setuptools noarch 0.9.8-7.el7 base 397 k
setools-libs x86_64 3.3.8-4.el7 base 620 k
subscription-manager-rhsm-certificates x86_64 1.24.13-3.el7.centos updates 228 k
yajl x86_64 2.0.4-4.el7 base 39 k
Updating for dependencies:
device-mapper x86_64 7:1.02.158-2.el7_7.2 updates 294 k
device-mapper-libs x86_64 7:1.02.158-2.el7_7.2 updates 322 k
Transaction Summary
===================================================================================================================================================
Install 1 Package (+32 Dependent packages)
Upgrade ( 2 Dependent packages)
Total download size: 29 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/extras/packages/atomic-registries-1.22.1-29.gitb507039.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for atomic-registries-1.22.1-29.gitb507039.el7.x86_64.rpm is not installed
(1/35): atomic-registries-1.22.1-29.gitb507039.el7.x86_64.rpm | 35 kB 00:00:00
Public key for audit-libs-python-2.8.5-4.el7.x86_64.rpm is not installed
(2/35): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(3/35): PyYAML-3.10-11.el7.x86_64.rpm | 153 kB 00:00:00
(4/35): container-selinux-2.107-3.el7.noarch.rpm | 39 kB 00:00:00
Public key for device-mapper-1.02.158-2.el7_7.2.x86_64.rpm is not installed
(5/35): device-mapper-1.02.158-2.el7_7.2.x86_64.rpm | 294 kB 00:00:00
(6/35): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
(7/35): container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch.rpm | 35 kB 00:00:00
(8/35): containers-common-0.1.37-3.el7.centos.x86_64.rpm | 21 kB 00:00:00
(9/35): device-mapper-event-libs-1.02.158-2.el7_7.2.x86_64.rpm | 189 kB 00:00:00
(10/35): device-mapper-event-1.02.158-2.el7_7.2.x86_64.rpm | 190 kB 00:00:00
(11/35): docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64.rpm | 97 kB 00:00:00
(12/35): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
(13/35): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(14/35): libseccomp-2.3.1-3.el7.x86_64.rpm | 56 kB 00:00:00
(15/35): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(16/35): device-mapper-libs-1.02.158-2.el7_7.2.x86_64.rpm | 322 kB 00:00:00
(17/35): libyaml-0.1.4-11.el7_0.x86_64.rpm | 55 kB 00:00:00
(18/35): lvm2-2.02.185-2.el7_7.2.x86_64.rpm | 1.3 MB 00:00:00
(19/35): lvm2-libs-2.02.185-2.el7_7.2.x86_64.rpm | 1.1 MB 00:00:00
(20/35): docker-client-1.13.1-103.git7f2769b.el7.centos.x86_64.rpm | 3.9 MB 00:00:02
(21/35): oci-umount-2.5-3.el7.x86_64.rpm | 33 kB 00:00:00
(22/35): device-mapper-persistent-data-0.8.5-1.el7.x86_64.rpm | 423 kB 00:00:02
(23/35): policycoreutils-python-2.5-33.el7.x86_64.rpm | 457 kB 00:00:00
(24/35): python-backports-1.0-8.el7.x86_64.rpm | 5.8 kB 00:00:00
(25/35): python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm | 13 kB 00:00:00
(26/35): python-ipaddress-1.0.16-2.el7.noarch.rpm | 34 kB 00:00:00
(27/35): python-pytoml-0.1.14-1.git7dea353.el7.noarch.rpm | 18 kB 00:00:00
(28/35): oci-register-machine-0-6.git2b44233.el7.x86_64.rpm | 1.1 MB 00:00:01
(29/35): python-setuptools-0.9.8-7.el7.noarch.rpm | 397 kB 00:00:00
(30/35): subscription-manager-rhsm-certificates-1.24.13-3.el7.centos.x86_64.rpm | 228 kB 00:00:00
(31/35): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(32/35): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
(33/35): yajl-2.0.4-4.el7.x86_64.rpm | 39 kB 00:00:00
(34/35): docker-1.13.1-103.git7f2769b.el7.centos.x86_64.rpm | 18 MB 00:00:05
oci-systemd-hook-0.2.0-1.git05 FAILED
http://mirrors.ustc.edu.cn/centos/7.7.1908/extras/x86_64/Packages/oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64.rpm: [Errno 12] Timeout on http://mirrors.ustc.edu.cn/centos/7.7.1908/extras/x86_64/Packages/oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(35/35): oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64.rpm | 34 kB 00:00:00
---------------------------------------------------------------------------------------------------------------------------------------------------
Total 916 kB/s | 29 MB 00:00:32
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) "
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libaio-0.3.109-13.el7.x86_64 1/37
Updating : 7:device-mapper-libs-1.02.158-2.el7_7.2.x86_64 2/37
Updating : 7:device-mapper-1.02.158-2.el7_7.2.x86_64 3/37
Installing : 7:device-mapper-event-libs-1.02.158-2.el7_7.2.x86_64 4/37
Installing : yajl-2.0.4-4.el7.x86_64 5/37
Installing : 2:oci-umount-2.5-3.el7.x86_64 6/37
Installing : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64 7/37
Installing : 7:device-mapper-event-1.02.158-2.el7_7.2.x86_64 8/37
Installing : 7:lvm2-libs-2.02.185-2.el7_7.2.x86_64 9/37
Installing : device-mapper-persistent-data-0.8.5-1.el7.x86_64 10/37
Installing : 7:lvm2-2.02.185-2.el7_7.2.x86_64 11/37
Installing : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch 12/37
Installing : libcgroup-0.41-21.el7.x86_64 13/37
Installing : subscription-manager-rhsm-certificates-1.24.13-3.el7.centos.x86_64 14/37
Installing : python-ipaddress-1.0.16-2.el7.noarch 15/37
Installing : libyaml-0.1.4-11.el7_0.x86_64 16/37
Installing : PyYAML-3.10-11.el7.x86_64 17/37
Installing : audit-libs-python-2.8.5-4.el7.x86_64 18/37
Installing : python-backports-1.0-8.el7.x86_64 19/37
Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 20/37
Installing : python-setuptools-0.9.8-7.el7.noarch 21/37
Installing : 1:oci-register-machine-0-6.git2b44233.el7.x86_64 22/37
Installing : libsemanage-python-2.5-14.el7.x86_64 23/37
Installing : setools-libs-3.3.8-4.el7.x86_64 24/37
Installing : python-pytoml-0.1.14-1.git7dea353.el7.noarch 25/37
Installing : 1:atomic-registries-1.22.1-29.gitb507039.el7.x86_64 26/37
Installing : 1:containers-common-0.1.37-3.el7.centos.x86_64 27/37
Installing : python-IPy-0.75-6.el7.noarch 28/37
Installing : checkpolicy-2.5-8.el7.x86_64 29/37
Installing : policycoreutils-python-2.5-33.el7.x86_64 30/37
Installing : 2:container-selinux-2.107-3.el7.noarch 31/37
setsebool: SELinux is disabled.
Installing : 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64 32/37
Installing : 2:docker-client-1.13.1-103.git7f2769b.el7.centos.x86_64 33/37
Installing : libseccomp-2.3.1-3.el7.x86_64 34/37
Installing : 2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64 35/37
Cleanup : 7:device-mapper-libs-1.02.158-2.el7.x86_64 36/37
Cleanup : 7:device-mapper-1.02.158-2.el7.x86_64 37/37
Verifying : 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64 1/37
Verifying : 2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64 2/37
Verifying : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 3/37
Verifying : device-mapper-persistent-data-0.8.5-1.el7.x86_64 4/37
Verifying : 2:container-selinux-2.107-3.el7.noarch 5/37
Verifying : libseccomp-2.3.1-3.el7.x86_64 6/37
Verifying : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch 7/37
Verifying : 1:atomic-registries-1.22.1-29.gitb507039.el7.x86_64 8/37
Verifying : python-setuptools-0.9.8-7.el7.noarch 9/37
Verifying : 7:device-mapper-event-libs-1.02.158-2.el7_7.2.x86_64 10/37
Verifying : 7:device-mapper-1.02.158-2.el7_7.2.x86_64 11/37
Verifying : checkpolicy-2.5-8.el7.x86_64 12/37
Verifying : python-IPy-0.75-6.el7.noarch 13/37
Verifying : 7:lvm2-libs-2.02.185-2.el7_7.2.x86_64 14/37
Verifying : 1:containers-common-0.1.37-3.el7.centos.x86_64 15/37
Verifying : 2:oci-umount-2.5-3.el7.x86_64 16/37
Verifying : 7:device-mapper-event-1.02.158-2.el7_7.2.x86_64 17/37
Verifying : python-pytoml-0.1.14-1.git7dea353.el7.noarch 18/37
Verifying : libaio-0.3.109-13.el7.x86_64 19/37
Verifying : setools-libs-3.3.8-4.el7.x86_64 20/37
Verifying : 7:device-mapper-libs-1.02.158-2.el7_7.2.x86_64 21/37
Verifying : policycoreutils-python-2.5-33.el7.x86_64 22/37
Verifying : libsemanage-python-2.5-14.el7.x86_64 23/37
Verifying : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64 24/37
Verifying : 2:docker-client-1.13.1-103.git7f2769b.el7.centos.x86_64 25/37
Verifying : 1:oci-register-machine-0-6.git2b44233.el7.x86_64 26/37
Verifying : python-backports-1.0-8.el7.x86_64 27/37
Verifying : yajl-2.0.4-4.el7.x86_64 28/37
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 29/37
Verifying : libyaml-0.1.4-11.el7_0.x86_64 30/37
Verifying : 7:lvm2-2.02.185-2.el7_7.2.x86_64 31/37
Verifying : python-ipaddress-1.0.16-2.el7.noarch 32/37
Verifying : PyYAML-3.10-11.el7.x86_64 33/37
Verifying : subscription-manager-rhsm-certificates-1.24.13-3.el7.centos.x86_64 34/37
Verifying : libcgroup-0.41-21.el7.x86_64 35/37
Verifying : 7:device-mapper-1.02.158-2.el7.x86_64 36/37
Verifying : 7:device-mapper-libs-1.02.158-2.el7.x86_64 37/37
Installed:
docker.x86_64 2:1.13.1-103.git7f2769b.el7.centos
Dependency Installed:
PyYAML.x86_64 0:3.10-11.el7 atomic-registries.x86_64 1:1.22.1-29.gitb507039.el7
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7
container-selinux.noarch 2:2.107-3.el7 container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7
containers-common.x86_64 1:0.1.37-3.el7.centos device-mapper-event.x86_64 7:1.02.158-2.el7_7.2
device-mapper-event-libs.x86_64 7:1.02.158-2.el7_7.2 device-mapper-persistent-data.x86_64 0:0.8.5-1.el7
docker-client.x86_64 2:1.13.1-103.git7f2769b.el7.centos docker-common.x86_64 2:1.13.1-103.git7f2769b.el7.centos
libaio.x86_64 0:0.3.109-13.el7 libcgroup.x86_64 0:0.41-21.el7
libseccomp.x86_64 0:2.3.1-3.el7 libsemanage-python.x86_64 0:2.5-14.el7
libyaml.x86_64 0:0.1.4-11.el7_0 lvm2.x86_64 7:2.02.185-2.el7_7.2
lvm2-libs.x86_64 7:2.02.185-2.el7_7.2 oci-register-machine.x86_64 1:0-6.git2b44233.el7
oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6 oci-umount.x86_64 2:2.5-3.el7
policycoreutils-python.x86_64 0:2.5-33.el7 python-IPy.noarch 0:0.75-6.el7
python-backports.x86_64 0:1.0-8.el7 python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7
python-ipaddress.noarch 0:1.0.16-2.el7 python-pytoml.noarch 0:0.1.14-1.git7dea353.el7
python-setuptools.noarch 0:0.9.8-7.el7 setools-libs.x86_64 0:3.3.8-4.el7
subscription-manager-rhsm-certificates.x86_64 0:1.24.13-3.el7.centos yajl.x86_64 0:2.0.4-4.el7
Dependency Updated:
device-mapper.x86_64 7:1.02.158-2.el7_7.2 device-mapper-libs.x86_64 7:1.02.158-2.el7_7.2
Complete!
[root@ecs-s6 ~]#
启动docker:service docker start
[root@ecs-s6 ~]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@ecs-s6 ~]#
查看docker状态:ps -ef|grep docker
[root@ecs-s6 ~]# ps -ef|grep docker
root 20283 1 0 14:03 ? 00:00:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2
root 20289 20283 0 14:03 ? 00:00:00 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc --runtime-args --systemd-cgroup=true
root 20373 19893 0 14:03 pts/0 00:00:00 grep --color=auto docker
[root@ecs-s6 ~]#
安装MySQL,直接安装5.7.28版本
[root@ecs-s6 ~]# docker pull mysql:5.7.28
Trying to pull repository docker.io/library/mysql ...
5.7.28: Pulling from docker.io/library/mysql
d599a449871e: Pull complete
f287049d3170: Pull complete
08947732a1b0: Pull complete
96f3056887f2: Pull complete
871f7f65f017: Pull complete
1dd50c4b99cb: Pull complete
5bcbdf508448: Pull complete
02a97db830bd: Pull complete
c09912a99bce: Pull complete
08a981fc6a89: Pull complete
818a84239152: Pull complete
Digest: sha256:5779c71a4730da36f013a23a437b5831198e68e634575f487d37a0639470e3a8
Status: Downloaded newer image for docker.io/mysql:5.7.28
[root@ecs-s6 ~]#
运行容器查看:docker ps
在Docker容器中创建并启动MySQL:docker run --name confmng -p 3306:3306 -e MYSQL_ROOT_PASSWORD=HaoXX1980 -d mysql:5.7.28
[root@ecs-s6 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
23bac5f2be92 mysql:5.7.28 "docker-entrypoint..." 14 seconds ago Up 13 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp confmng
[root@ecs-s6 ~]#
[root@ecs-s6 ~]# docker run --name confmng -p 3306:3306 -e MYSQL_ROOT_PASSWORD=HaoXX1980 -d mysql:5.7.28
23bac5f2be928f47ff226659f463b32a084f1f98a504b05821c2d28990d1ce79
[root@ecs-s6 ~]#
打开防火墙并开通访问端口
[root@ecs-s6 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@ecs-s6 ~]# systemctl start firewalld
[root@ecs-s6 ~]#
[root@ecs-s6 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2019-12-17 14:31:27 CST; 4s ago
Docs: man:firewalld(1)
Main PID: 20797 (firewalld)
Tasks: 2
Memory: 25.6M
CGroup: /system.slice/firewalld.service
└─20797 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
Dec 17 14:31:25 ecs-s6 systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 17 14:31:27 ecs-s6 systemd[1]: Started firewalld - dynamic firewall daemon.
[root@ecs-s6 ~]#
[root@ecs-s6 ~]#
[root@ecs-s6 ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@ecs-s6 ~]#
重新加载防火墙配置,看看是否生效
[root@ecs-s6 ~]# firewall-cmd --reload
success
[root@ecs-s6 ~]#
[root@ecs-s6 ~]# firewall-cmd --zone=public --query-port=3306/tcp
yes
[root@ecs-s6 ~]#
登录MySQL设定远程访问权限
[root@ecs-s6 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
23bac5f2be92 mysql:5.7.28 "docker-entrypoint..." 12 minutes ago Up 12 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp confmng
[root@ecs-s6 ~]#
[root@ecs-s6 ~]# docker exec -it confmng bash
root@23bac5f2be92:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'MaoXX1080';
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
root@23bac5f2be92:/# exit
exit
[root@ecs-s6 ~]#
因为购买的华为云的ECS,所以需要通过华为云的控制台开通华为云服务器的防火墙入口。参考如下截图过程。
# 显示镜像列表
docker images
# 显示容器列表
docker ps
# 指定镜像, 运行一个容器
docker run IMAGE_ID
# 操作容器状态
docker start/stop/pause/unpause/kill/restart CONTAINER_ID
# 给指定镜像命名
docker tag IMAGE_ID [REGISTRYHOST/][USERNAME/]NAME[:TAG]
# 下载, 推送镜像到 **Docker registry server** , NAME 部分包括了服务地址
docker pull/push NAME:TAG
# 删除容器, 镜像
docker rm/rmi CONTAINER_ID/IMAGE_ID
# 查看细节信息
docker inspect CONTAINER_ID/IMAGE_ID
# 查看指定的运行容器的进程情况
docker top CONTAINER_ID
# 查看系统配置信息
docker info
# 保存, 恢复镜像信息
docker save/load
# 从容器创建镜像
docker commit CONTAINER_ID
# 导出一个容器
docker export 容器ID > xxx.tar
# 恢复一个容器
docker import - < xxx.tar
# 从镜像复制文件到实体机
docker cp CONTAINER_ID:PATH HOSTPATH
# 查看容器相对于镜像的文件变化
docker diff CONTAINER_ID
# 查看容器日志
docker logs CONTAINER_ID
# 从 `Dockerfile` 构建镜像
docker build
# 查看镜像的构建历史
docker history IMAGE_ID