Install MySQL 5.7 in the Docker
Install Docker on Oracle Linux 7
在Oracle Linux 7.1上安裝Docker
1.首先使用正確的yum設定來升級Oracle Linux 7.1例項。為了安裝最新的Docker版本(18.9.1.ce),需要ol7_latest,ol7_uekr4與ol7_addons啟用
[root@localhost /]# cd /etc/yum.repos.d/ [root@localhost /]#wget [root@localhost yum.repos.d]# vi public-yum-ol7.repo [ol7_latest] name=Oracle Linux $releasever Latest ($basearch) baseurl= gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle gpgcheck=1 enabled=1 [ol7_UEKR4] name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux $releasever ($basearch) baseurl= gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle gpgcheck=1 enabled=1 [ol7_addons] name=Oracle Linux $releasever Add ons ($basearch) baseurl= gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle gpgcheck=1 enabled=1
2.開始安裝docker
[root@localhost yum.repos.d]# yum install docker-engine Loaded plugins: langpacks ol7_UEKR4 | 2.5 kB 00:00:00 ol7_addons | 1.2 kB 00:00:00 ol7_latest | 2.7 kB 00:00:00 (1/4): ol7_addons/x86_64/updateinfo | 60 kB 00:00:00 (2/4): ol7_UEKR4/x86_64/updateinfo | 82 kB 00:00:01 (3/4): ol7_addons/x86_64/primary | 82 kB 00:00:02 (4/4): ol7_UEKR4/x86_64/primary_db | 4.0 MB 00:03:38 ol7_addons 328/328 Resolving Dependencies --> Running transaction check ---> Package docker-engine.x86_64 0:18.09.1.ol-1.0.5.el7 will be installed --> Processing Dependency: container-selinux >= 2:2.77 for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64 --> Processing Dependency: libseccomp >= 2.3 for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64 --> Processing Dependency: containerd for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64 --> Processing Dependency: docker-cli for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64 --> Processing Dependency: runc for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64 --> Processing Dependency: libdevmapper.so.1.02(DM_1_02_97)(64bit) for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64 --> Processing Dependency: libsystemd.so.0(LIBSYSTEMD_209)(64bit) for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64 --> Processing Dependency: libsystemd.so.0()(64bit) for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64 --> Running transaction check ---> Package container-selinux.noarch 2:2.77-5.el7 will be installed --> Processing Dependency: selinux-policy-base >= 3.13.1-216.el7 for package: 2:container-selinux-2.77-5.el7.noarch --> Processing Dependency: selinux-policy >= 3.13.1-216.el7 for package: 2:container-selinux-2.77-5.el7.noarch --> Processing Dependency: policycoreutils >= 2.5-11 for package: 2:container-selinux-2.77-5.el7.noarch --> Processing Dependency: selinux-policy-targeted >= 3.13.1-216.el7 for package: 2:container-selinux-2.77-5.el7.noarch ---> Package containerd.x86_64 0:1.2.0-1.0.5.el7 will be installed ---> Package device-mapper-libs.x86_64 7:1.02.93-3.el7 will be updated --> Processing Dependency: device-mapper-libs = 7:1.02.93-3.el7 for package: 7:device-mapper-1.02.93-3.el7.x86_64 ---> Package device-mapper-libs.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update ---> Package docker-cli.x86_64 0:18.09.1.ol-1.0.5.el7 will be installed ---> Package libseccomp.x86_64 0:2.1.1-2.el7 will be updated ---> Package libseccomp.x86_64 0:2.3.1-3.el7 will be an update ---> Package runc.x86_64 0:1.0.0-19.rc5.git4bb1fe4.0.3.el7 will be installed --> Processing Dependency: criu for package: runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64 ---> Package systemd-libs.x86_64 0:208-20.0.1.el7 will be updated --> Processing Dependency: systemd-libs = 208-20.0.1.el7 for package: systemd-208-20.0.1.el7.x86_64 ---> Package systemd-libs.x86_64 0:219-62.0.4.el7_6.7 will be an update --> Processing Dependency: liblz4.so.1()(64bit) for package: systemd-libs-219-62.0.4.el7_6.7.x86_64 --> Running transaction check ---> Package criu.x86_64 0:3.9-5.el7 will be installed --> Processing Dependency: libprotobuf-c.so.1(LIBPROTOBUF_C_1.0.0)(64bit) for package: criu-3.9-5.el7.x86_64 --> Processing Dependency: libnl-3.so.200(libnl_3)(64bit) for package: criu-3.9-5.el7.x86_64 --> Processing Dependency: libprotobuf-c.so.1()(64bit) for package: criu-3.9-5.el7.x86_64 --> Processing Dependency: libnet.so.1()(64bit) for package: criu-3.9-5.el7.x86_64 ---> Package device-mapper.x86_64 7:1.02.93-3.el7 will be updated --> Processing Dependency: device-mapper = 7:1.02.93-3.el7 for package: 7:device-mapper-event-1.02.93-3.el7.x86_64 ---> Package device-mapper.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update ---> Package lz4.x86_64 0:1.7.5-2.0.1.el7 will be installed ---> Package policycoreutils.x86_64 0:2.2.5-15.0.1.el7 will be updated --> Processing Dependency: policycoreutils = 2.2.5-15.0.1.el7 for package: policycoreutils-python-2.2.5-15.0.1.el7.x86_64 ---> Package policycoreutils.x86_64 0:2.5-29.0.1.el7_6.1 will be an update --> Processing Dependency: libsemanage >= 2.5-14 for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64 --> Processing Dependency: libsepol >= 2.5-10 for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64 --> Processing Dependency: libselinux-utils >= 2.5-14 for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64 --> Processing Dependency: libsepol.so.1(LIBSEPOL_1.1)(64bit) for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64 --> Processing Dependency: libsemanage.so.1(LIBSEMANAGE_1.1)(64bit) for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64 --> Processing Dependency: libsepol.so.1(LIBSEPOL_1.0)(64bit) for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64 ---> Package selinux-policy.noarch 0:3.13.1-23.0.1.el7 will be updated ---> Package selinux-policy.noarch 0:3.13.1-229.0.3.el7_6.12 will be an update ---> Package selinux-policy-targeted.noarch 0:3.13.1-23.0.1.el7 will be updated ---> Package selinux-policy-targeted.noarch 0:3.13.1-229.0.3.el7_6.12 will be an update ---> Package systemd.x86_64 0:208-20.0.1.el7 will be updated --> Processing Dependency: systemd = 208-20.0.1.el7 for package: libgudev1-208-20.0.1.el7.x86_64 --> Processing Dependency: systemd = 208-20.0.1.el7 for package: systemd-sysv-208-20.0.1.el7.x86_64 --> Processing Dependency: systemd = 208-20.0.1.el7 for package: systemd-python-208-20.0.1.el7.x86_64 ---> Package systemd.x86_64 0:219-62.0.4.el7_6.7 will be an update --> Processing Dependency: kmod >= 18-4 for package: systemd-219-62.0.4.el7_6.7.x86_64 --> Processing Dependency: libcryptsetup.so.12(CRYPTSETUP_2.0)(64bit) for package: systemd-219-62.0.4.el7_6.7.x86_64 --> Processing Dependency: libcryptsetup.so.12()(64bit) for package: systemd-219-62.0.4.el7_6.7.x86_64 --> Running transaction check ---> Package cryptsetup-libs.x86_64 0:1.6.6-3.el7 will be updated --> Processing Dependency: cryptsetup-libs = 1.6.6-3.el7 for package: cryptsetup-python-1.6.6-3.el7.x86_64 --> Processing Dependency: cryptsetup-libs(x86-64) = 1.6.6-3.el7 for package: cryptsetup-1.6.6-3.el7.x86_64 ---> Package cryptsetup-libs.x86_64 0:2.0.3-3.el7 will be an update ---> Package device-mapper-event.x86_64 7:1.02.93-3.el7 will be updated --> Processing Dependency: device-mapper-event = 7:1.02.93-3.el7 for package: 7:lvm2-libs-2.02.115-3.el7.x86_64 ---> Package device-mapper-event.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update --> Processing Dependency: device-mapper-event-libs = 7:1.02.149-10.0.3.el7_6.8 for package: 7:device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64 ---> Package kmod.x86_64 0:14-10.el7 will be updated ---> Package kmod.x86_64 0:20-23.0.1.el7 will be an update ---> Package libgudev1.x86_64 0:208-20.0.1.el7 will be updated ---> Package libgudev1.x86_64 0:219-62.0.4.el7_6.7 will be an update --> Processing Dependency: glib2 >= 2.42 for package: libgudev1-219-62.0.4.el7_6.7.x86_64 ---> Package libnet.x86_64 0:1.1.6-7.el7 will be installed ---> Package libnl3.x86_64 0:3.2.21-8.0.1.el7 will be updated --> Processing Dependency: libnl3 = 3.2.21-8.0.1.el7 for package: libnl3-cli-3.2.21-8.0.1.el7.x86_64 ---> Package libnl3.x86_64 0:3.2.28-4.el7 will be an update ---> Package libselinux-utils.x86_64 0:2.2.2-6.el7 will be updated ---> Package libselinux-utils.x86_64 0:2.5-14.1.el7 will be an update --> Processing Dependency: libselinux(x86-64) = 2.5-14.1.el7 for package: libselinux-utils-2.5-14.1.el7.x86_64 ---> Package libsemanage.x86_64 0:2.1.10-16.el7 will be updated --> Processing Dependency: libsemanage = 2.1.10-16.el7 for package: libsemanage-python-2.1.10-16.el7.x86_64 ---> Package libsemanage.x86_64 0:2.5-14.el7 will be an update ---> Package libsepol.x86_64 0:2.1.9-3.el7 will be updated ---> Package libsepol.x86_64 0:2.5-10.el7 will be an update ---> Package policycoreutils-python.x86_64 0:2.2.5-15.0.1.el7 will be updated ---> Package policycoreutils-python.x86_64 0:2.5-29.0.1.el7_6.1 will be an update --> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64 ---> Package protobuf-c.x86_64 0:1.0.2-3.el7 will be installed ---> Package systemd-python.x86_64 0:208-20.0.1.el7 will be updated ---> Package systemd-python.x86_64 0:219-62.0.4.el7_6.7 will be an update ---> Package systemd-sysv.x86_64 0:208-20.0.1.el7 will be updated ---> Package systemd-sysv.x86_64 0:219-62.0.4.el7_6.7 will be an update --> Running transaction check ---> Package cryptsetup.x86_64 0:1.6.6-3.el7 will be updated ---> Package cryptsetup.x86_64 0:2.0.3-3.el7 will be an update ---> Package cryptsetup-python.x86_64 0:1.6.6-3.el7 will be updated ---> Package cryptsetup-python.x86_64 0:2.0.3-3.el7 will be an update ---> Package device-mapper-event-libs.x86_64 7:1.02.93-3.el7 will be updated ---> Package device-mapper-event-libs.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update ---> Package glib2.x86_64 0:2.40.0-4.el7 will be updated ---> Package glib2.x86_64 0:2.56.1-4.el7_6 will be an update ---> Package libnl3-cli.x86_64 0:3.2.21-8.0.1.el7 will be updated ---> Package libnl3-cli.x86_64 0:3.2.28-4.el7 will be an update ---> Package libselinux.x86_64 0:2.2.2-6.el7 will be updated --> Processing Dependency: libselinux = 2.2.2-6.el7 for package: libselinux-python-2.2.2-6.el7.x86_64 ---> Package libselinux.x86_64 0:2.5-14.1.el7 will be an update ---> Package libsemanage-python.x86_64 0:2.1.10-16.el7 will be updated ---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be an update ---> Package lvm2-libs.x86_64 7:2.02.115-3.el7 will be updated --> Processing Dependency: lvm2-libs = 7:2.02.115-3.el7 for package: 7:lvm2-2.02.115-3.el7.x86_64 --> Processing Dependency: lvm2-libs = 7:2.02.115-3.el7 for package: 7:lvm2-python-libs-2.02.115-3.el7.x86_64 ---> Package lvm2-libs.x86_64 7:2.02.180-10.0.3.el7_6.8 will be an update ---> Package setools-libs.x86_64 0:3.3.7-46.el7 will be updated ---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be an update --> Running transaction check ---> Package libselinux-python.x86_64 0:2.2.2-6.el7 will be updated ---> Package libselinux-python.x86_64 0:2.5-14.1.el7 will be an update ---> Package lvm2.x86_64 7:2.02.115-3.el7 will be updated ---> Package lvm2.x86_64 7:2.02.180-10.0.3.el7_6.8 will be an update --> Processing Dependency: device-mapper-persistent-data >= 0.7.0-0.1.rc6 for package: 7:lvm2-2.02.180-10.0.3.el7_6.8.x86_64 ---> Package lvm2-python-libs.x86_64 7:2.02.115-3.el7 will be updated ---> Package lvm2-python-libs.x86_64 7:2.02.180-10.0.3.el7_6.8 will be an update --> Running transaction check ---> Package device-mapper-persistent-data.x86_64 0:0.4.1-2.el7 will be updated ---> Package device-mapper-persistent-data.x86_64 0:0.7.3-3.el7 will be an update --> Processing Conflict: systemd-219-62.0.4.el7_6.7.x86_64 conflicts initscripts < 9.49.28-1 --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package initscripts.x86_64 0:9.49.24-1.0.1.el7 will be updated ---> Package initscripts.x86_64 0:9.49.46-1.0.1.el7 will be an update --> Processing Conflict: initscripts-9.49.46-1.0.1.el7.x86_64 conflicts redhat-release < 7.5-0.11 --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package redhat-release-server.x86_64 1:7.1-1.0.2.el7 will be updated ---> Package redhat-release-server.x86_64 1:7.6-4.0.1.el7 will be an update --> Processing Conflict: initscripts-9.49.46-1.0.1.el7.x86_64 conflicts oraclelinux-release < 7:7.5-1.0.3 --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package oraclelinux-release.x86_64 7:7.1-1.0.5.el7 will be updated ---> Package oraclelinux-release.x86_64 7:7.6-1.0.15.el7 will be an update --> Processing Conflict: systemd-219-62.0.4.el7_6.7.x86_64 conflicts dracut < 033-243 --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package dracut.x86_64 0:033-240.0.1.el7 will be updated --> Processing Dependency: dracut = 033-240.0.1.el7 for package: dracut-config-rescue-033-240.0.1.el7.x86_64 --> Processing Dependency: dracut = 033-240.0.1.el7 for package: dracut-network-033-240.0.1.el7.x86_64 ---> Package dracut.x86_64 0:033-554.0.3.el7 will be an update --> Running transaction check ---> Package dracut-config-rescue.x86_64 0:033-240.0.1.el7 will be updated ---> Package dracut-config-rescue.x86_64 0:033-554.0.3.el7 will be an update ---> Package dracut-network.x86_64 0:033-240.0.1.el7 will be updated ---> Package dracut-network.x86_64 0:033-554.0.3.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================================================================================ Installing: docker-engine x86_64 18.09.1.ol-1.0.5.el7 ol7_addons 19 M Updating: dracut x86_64 033-554.0.3.el7 ol7_latest 328 k initscripts x86_64 9.49.46-1.0.1.el7 ol7_latest 439 k oraclelinux-release x86_64 7:7.6-1.0.15.el7 ol7_latest 54 k redhat-release-server x86_64 1:7.6-4.0.1.el7 ol7_latest 9.8 k Installing for dependencies: container-selinux noarch 2:2.77-5.el7 ol7_addons 37 k containerd x86_64 1.2.0-1.0.5.el7 ol7_addons 21 M criu x86_64 3.9-5.el7 ol7_latest 432 k docker-cli x86_64 18.09.1.ol-1.0.5.el7 ol7_addons 14 M libnet x86_64 1.1.6-7.el7 ol7_latest 57 k lz4 x86_64 1.7.5-2.0.1.el7 ol7_latest 98 k protobuf-c x86_64 1.0.2-3.el7 ol7_latest 27 k runc x86_64 1.0.0-19.rc5.git4bb1fe4.0.3.el7 ol7_addons 1.9 M Updating for dependencies: cryptsetup x86_64 2.0.3-3.el7 ol7_latest 153 k cryptsetup-libs x86_64 2.0.3-3.el7 ol7_latest 337 k cryptsetup-python x86_64 2.0.3-3.el7 ol7_latest 35 k device-mapper x86_64 7:1.02.149-10.0.3.el7_6.8 ol7_latest 293 k device-mapper-event x86_64 7:1.02.149-10.0.3.el7_6.8 ol7_latest 188 k device-mapper-event-libs x86_64 7:1.02.149-10.0.3.el7_6.8 ol7_latest 188 k device-mapper-libs x86_64 7:1.02.149-10.0.3.el7_6.8 ol7_latest 320 k device-mapper-persistent-data x86_64 0.7.3-3.el7 ol7_latest 404 k dracut-config-rescue x86_64 033-554.0.3.el7 ol7_latest 60 k dracut-network x86_64 033-554.0.3.el7 ol7_latest 102 k glib2 x86_64 2.56.1-4.el7_6 ol7_latest 2.5 M kmod x86_64 20-23.0.1.el7 ol7_latest 121 k libgudev1 x86_64 219-62.0.4.el7_6.7 ol7_latest 96 k libnl3 x86_64 3.2.28-4.el7 ol7_latest 277 k libnl3-cli x86_64 3.2.28-4.el7 ol7_latest 159 k libseccomp x86_64 2.3.1-3.el7 ol7_latest 55 k libselinux x86_64 2.5-14.1.el7 ol7_latest 162 k libselinux-python x86_64 2.5-14.1.el7 ol7_latest 235 k libselinux-utils x86_64 2.5-14.1.el7 ol7_latest 151 k libsemanage x86_64 2.5-14.el7 ol7_latest 150 k libsemanage-python x86_64 2.5-14.el7 ol7_latest 112 k libsepol x86_64 2.5-10.el7 ol7_latest 297 k lvm2 x86_64 7:2.02.180-10.0.3.el7_6.8 ol7_latest 1.3 M lvm2-libs x86_64 7:2.02.180-10.0.3.el7_6.8 ol7_latest 1.1 M lvm2-python-libs x86_64 7:2.02.180-10.0.3.el7_6.8 ol7_latest 186 k policycoreutils x86_64 2.5-29.0.1.el7_6.1 ol7_latest 916 k policycoreutils-python x86_64 2.5-29.0.1.el7_6.1 ol7_latest 455 k selinux-policy noarch 3.13.1-229.0.3.el7_6.12 ol7_latest 484 k selinux-policy-targeted noarch 3.13.1-229.0.3.el7_6.12 ol7_latest 6.9 M setools-libs x86_64 3.3.8-4.el7 ol7_latest 620 k systemd x86_64 219-62.0.4.el7_6.7 ol7_latest 5.1 M systemd-libs x86_64 219-62.0.4.el7_6.7 ol7_latest 407 k systemd-python x86_64 219-62.0.4.el7_6.7 ol7_latest 133 k systemd-sysv x86_64 219-62.0.4.el7_6.7 ol7_latest 84 k Transaction Summary ============================================================================================================================================================================================================================================ Install 1 Package (+ 8 Dependent packages) Upgrade 4 Packages (+34 Dependent packages) Total download size: 81 M Is this ok [y/d/N]: y Downloading packages: No Presto metadata available for ol7_latest warning: /var/cache/yum/x86_64/7Server/ol7_latest/packages/cryptsetup-2.0.3-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY ] 373 kB/s | 1.6 MB 00:03:39 ETA Public key for cryptsetup-2.0.3-3.el7.x86_64.rpm is not installed (1/47): cryptsetup-2.0.3-3.el7.x86_64.rpm | 153 kB 00:00:04 (2/47): criu-3.9-5.el7.x86_64.rpm | 432 kB 00:00:04 Public key for container-selinux-2.77-5.el7.noarch.rpm is not installed (3/47): container-selinux-2.77-5.el7.noarch.rpm | 37 kB 00:00:04 (4/47): cryptsetup-python-2.0.3-3.el7.x86_64.rpm | 35 kB 00:00:00 (5/47): cryptsetup-libs-2.0.3-3.el7.x86_64.rpm | 337 kB 00:00:01 (6/47): device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64.rpm | 188 kB 00:00:00 (7/47): device-mapper-1.02.149-10.0.3.el7_6.8.x86_64.rpm | 293 kB 00:00:01 (8/47): device-mapper-event-libs-1.02.149-10.0.3.el7_6.8.x86_64.rpm | 188 kB 00:00:00 (9/47): device-mapper-persistent-data-0.7.3-3.el7.x86_64.rpm | 404 kB 00:00:00 (10/47): device-mapper-libs-1.02.149-10.0.3.el7_6.8.x86_64.rpm | 320 kB 00:00:02 (11/47): containerd-1.2.0-1.0.5.el7.x86_64.rpm | 21 MB 00:00:13 (12/47): dracut-config-rescue-033-554.0.3.el7.x86_64.rpm | 60 kB 00:00:01 (13/47): dracut-network-033-554.0.3.el7.x86_64.rpm | 102 kB 00:00:00 (14/47): dracut-033-554.0.3.el7.x86_64.rpm | 328 kB 00:00:02 (15/47): initscripts-9.49.46-1.0.1.el7.x86_64.rpm | 439 kB 00:00:00 (16/47): kmod-20-23.0.1.el7.x86_64.rpm | 121 kB 00:00:00 (17/47): libgudev1-219-62.0.4.el7_6.7.x86_64.rpm | 96 kB 00:00:00 (18/47): glib2-2.56.1-4.el7_6.x86_64.rpm | 2.5 MB 00:00:02 (19/47): libnl3-3.2.28-4.el7.x86_64.rpm | 277 kB 00:00:00 (20/47): docker-cli-18.09.1.ol-1.0.5.el7.x86_64.rpm | 14 MB 00:00:12 (21/47): libnet-1.1.6-7.el7.x86_64.rpm | 57 kB 00:00:01 (22/47): libseccomp-2.3.1-3.el7.x86_64.rpm | 55 kB 00:00:00 (23/47): libselinux-2.5-14.1.el7.x86_64.rpm | 162 kB 00:00:00 (24/47): libnl3-cli-3.2.28-4.el7.x86_64.rpm | 159 kB 00:00:00 (25/47): libselinux-python-2.5-14.1.el7.x86_64.rpm | 235 kB 00:00:00 (26/47): libselinux-utils-2.5-14.1.el7.x86_64.rpm | 151 kB 00:00:00 (27/47): libsemanage-python-2.5-14.el7.x86_64.rpm | 112 kB 00:00:00 (28/47): libsemanage-2.5-14.el7.x86_64.rpm | 150 kB 00:00:00 (29/47): libsepol-2.5-10.el7.x86_64.rpm | 297 kB 00:00:00 (30/47): lvm2-2.02.180-10.0.3.el7_6.8.x86_64.rpm | 1.3 MB 00:00:00 (31/47): lvm2-python-libs-2.02.180-10.0.3.el7_6.8.x86_64.rpm | 186 kB 00:00:00 (32/47): lvm2-libs-2.02.180-10.0.3.el7_6.8.x86_64.rpm | 1.1 MB 00:00:01 (33/47): lz4-1.7.5-2.0.1.el7.x86_64.rpm | 98 kB 00:00:00 (34/47): oraclelinux-release-7.6-1.0.15.el7.x86_64.rpm | 54 kB 00:00:00 (35/47): policycoreutils-2.5-29.0.1.el7_6.1.x86_64.rpm | 916 kB 00:00:00 (36/47): policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64.rpm | 455 kB 00:00:00 (37/47): redhat-release-server-7.6-4.0.1.el7.x86_64.rpm | 9.8 kB 00:00:00 (38/47): docker-engine-18.09.1.ol-1.0.5.el7.x86_64.rpm | 19 MB 00:00:10 (39/47): selinux-policy-3.13.1-229.0.3.el7_6.12.noarch.rpm | 484 kB 00:00:00 (40/47): protobuf-c-1.0.2-3.el7.x86_64.rpm | 27 kB 00:00:02 (41/47): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00 (42/47): runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64.rpm | 1.9 MB 00:00:04 (43/47): selinux-policy-targeted-3.13.1-229.0.3.el7_6.12.noarch.rpm | 6.9 MB 00:00:03 (44/47): systemd-libs-219-62.0.4.el7_6.7.x86_64.rpm | 407 kB 00:00:00 (45/47): systemd-python-219-62.0.4.el7_6.7.x86_64.rpm | 133 kB 00:00:00 (46/47): systemd-sysv-219-62.0.4.el7_6.7.x86_64.rpm | 84 kB 00:00:00 (47/47): systemd-219-62.0.4.el7_6.7.x86_64.rpm | 5.1 MB 00:00:04 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 2.8 MB/s | 81 MB 00:00:29 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle Importing GPG key 0xEC551F03: Userid : "Oracle OSS group (Open Source Software group) " Fingerprint: 4214 4123 fecf c55b 9086 313d 72f9 7b74 ec55 1f03 Package : 7:oraclelinux-release-7.1-1.0.5.el7.x86_64 (@anaconda/7.1) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : libsepol-2.5-10.el7.x86_64 1/85 Updating : libselinux-2.5-14.1.el7.x86_64 2/85 Updating : libsemanage-2.5-14.el7.x86_64 3/85 Installing : lz4-1.7.5-2.0.1.el7.x86_64 4/85 Updating : systemd-libs-219-62.0.4.el7_6.7.x86_64 5/85 Updating : 1:redhat-release-server-7.6-4.0.1.el7.x86_64 6/85 Updating : cryptsetup-libs-2.0.3-3.el7.x86_64 7/85 Updating : 7:device-mapper-libs-1.02.149-10.0.3.el7_6.8.x86_64 8/85 Updating : 7:device-mapper-1.02.149-10.0.3.el7_6.8.x86_64 9/85 Updating : systemd-219-62.0.4.el7_6.7.x86_64 10/85 Updating : dracut-033-554.0.3.el7.x86_64 11/85 Updating : kmod-20-23.0.1.el7.x86_64 12/85 Updating : 7:device-mapper-event-libs-1.02.149-10.0.3.el7_6.8.x86_64 13/85 Updating : libseccomp-2.3.1-3.el7.x86_64 14/85 Updating : glib2-2.56.1-4.el7_6.x86_64 15/85 Updating : libselinux-utils-2.5-14.1.el7.x86_64 16/85 Updating : policycoreutils-2.5-29.0.1.el7_6.1.x86_64 17/85 Updating : selinux-policy-3.13.1-229.0.3.el7_6.12.noarch 18/85 Updating : libnl3-3.2.28-4.el7.x86_64 19/85 Updating : selinux-policy-targeted-3.13.1-229.0.3.el7_6.12.noarch 20/85 Updating : 7:device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64 21/85 Updating : 7:lvm2-libs-2.02.180-10.0.3.el7_6.8.x86_64 22/85 Updating : 7:oraclelinux-release-7.6-1.0.15.el7.x86_64 23/85 Updating : libsemanage-python-2.5-14.el7.x86_64 24/85 Updating : libselinux-python-2.5-14.1.el7.x86_64 25/85 Updating : setools-libs-3.3.8-4.el7.x86_64 26/85 Updating : policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64 27/85 Installing : 2:container-selinux-2.77-5.el7.noarch 28/85 Installing : containerd-1.2.0-1.0.5.el7.x86_64 29/85 Installing : docker-cli-18.09.1.ol-1.0.5.el7.x86_64 30/85 Installing : libnet-1.1.6-7.el7.x86_64 31/85 Installing : protobuf-c-1.0.2-3.el7.x86_64 32/85 Installing : criu-3.9-5.el7.x86_64 33/85 Installing : runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64 34/85 Updating : device-mapper-persistent-data-0.7.3-3.el7.x86_64 35/85 Updating : 7:lvm2-2.02.180-10.0.3.el7_6.8.x86_64 36/85 Created symlink from /etc/systemd/system/sysinit.target.wants/lvm2-lvmpolld.socket to /usr/lib/systemd/system/lvm2-lvmpolld.socket. Installing : docker-engine-18.09.1.ol-1.0.5.el7.x86_64 37/85 Updating : initscripts-9.49.46-1.0.1.el7.x86_64 38/85 Updating : 7:lvm2-python-libs-2.02.180-10.0.3.el7_6.8.x86_64 39/85 Updating : libnl3-cli-3.2.28-4.el7.x86_64 40/85 Updating : libgudev1-219-62.0.4.el7_6.7.x86_64 41/85 Updating : dracut-network-033-554.0.3.el7.x86_64 42/85 Updating : dracut-config-rescue-033-554.0.3.el7.x86_64 43/85 Updating : systemd-sysv-219-62.0.4.el7_6.7.x86_64 44/85 Updating : systemd-python-219-62.0.4.el7_6.7.x86_64 45/85 Updating : cryptsetup-python-2.0.3-3.el7.x86_64 46/85 Updating : cryptsetup-2.0.3-3.el7.x86_64 47/85 Cleanup : 7:lvm2-2.02.115-3.el7.x86_64 48/85 Cleanup : policycoreutils-python-2.2.5-15.0.1.el7.x86_64 49/85 UPGRADE: Automatically re-enabling default systemd units: brandbot.path rhel-autorelabel.service rhel-autorelabel-mark.service rhel-configure.service rhel-dmesg.service rhel-domainname.service rhel-import-state.service rhel-loadmodules.service rhel-readonly.service Cleanup : initscripts-9.49.24-1.0.1.el7.x86_64 50/85 Cleanup : libgudev1-208-20.0.1.el7.x86_64 51/85 Cleanup : selinux-policy-targeted-3.13.1-23.0.1.el7.noarch 52/85 Cleanup : selinux-policy-3.13.1-23.0.1.el7.noarch 53/85 Cleanup : 7:oraclelinux-release-7.1-1.0.5.el7.x86_64 54/85 Cleanup : dracut-config-rescue-033-240.0.1.el7.x86_64 55/85 Cleanup : systemd-sysv-208-20.0.1.el7.x86_64 56/85 Cleanup : dracut-network-033-240.0.1.el7.x86_64 57/85 Cleanup : policycoreutils-2.2.5-15.0.1.el7.x86_64 58/85 Cleanup : systemd-python-208-20.0.1.el7.x86_64 59/85 Cleanup : dracut-033-240.0.1.el7.x86_64 60/85 Cleanup : setools-libs-3.3.7-46.el7.x86_64 61/85 Cleanup : libselinux-utils-2.2.2-6.el7.x86_64 62/85 Cleanup : glib2-2.40.0-4.el7.x86_64 63/85 Cleanup : libselinux-python-2.2.2-6.el7.x86_64 64/85 Cleanup : libsemanage-python-2.1.10-16.el7.x86_64 65/85 Cleanup : libsemanage-2.1.10-16.el7.x86_64 66/85 Cleanup : cryptsetup-1.6.6-3.el7.x86_64 67/85 Cleanup : libnl3-cli-3.2.21-8.0.1.el7.x86_64 68/85 Cleanup : cryptsetup-python-1.6.6-3.el7.x86_64 69/85 Cleanup : 7:lvm2-python-libs-2.02.115-3.el7.x86_64 70/85 Cleanup : 7:lvm2-libs-2.02.115-3.el7.x86_64 71/85 Cleanup : 7:device-mapper-event-1.02.93-3.el7.x86_64 72/85 Cleanup : 7:device-mapper-event-libs-1.02.93-3.el7.x86_64 73/85 Cleanup : cryptsetup-libs-1.6.6-3.el7.x86_64 74/85 Cleanup : systemd-208-20.0.1.el7.x86_64 75/85 Cleanup : 7:device-mapper-1.02.93-3.el7.x86_64 76/85 Cleanup : 7:device-mapper-libs-1.02.93-3.el7.x86_64 77/85 Cleanup : 1:redhat-release-server-7.1-1.0.2.el7.x86_64 78/85 Cleanup : systemd-libs-208-20.0.1.el7.x86_64 79/85 Cleanup : libselinux-2.2.2-6.el7.x86_64 80/85 Cleanup : libsepol-2.1.9-3.el7.x86_64 81/85 Cleanup : kmod-14-10.el7.x86_64 82/85 Cleanup : libnl3-3.2.21-8.0.1.el7.x86_64 83/85 Cleanup : device-mapper-persistent-data-0.4.1-2.el7.x86_64 84/85 Cleanup : libseccomp-2.1.1-2.el7.x86_64 85/85 Verifying : 7:device-mapper-event-libs-1.02.149-10.0.3.el7_6.8.x86_64 1/85 Verifying : glib2-2.56.1-4.el7_6.x86_64 2/85 Verifying : docker-engine-18.09.1.ol-1.0.5.el7.x86_64 3/85 Verifying : policycoreutils-2.5-29.0.1.el7_6.1.x86_64 4/85 Verifying : libseccomp-2.3.1-3.el7.x86_64 5/85 Verifying : kmod-20-23.0.1.el7.x86_64 6/85 Verifying : 7:device-mapper-libs-1.02.149-10.0.3.el7_6.8.x86_64 7/85 Verifying : 7:lvm2-python-libs-2.02.180-10.0.3.el7_6.8.x86_64 8/85 Verifying : libgudev1-219-62.0.4.el7_6.7.x86_64 9/85 Verifying : cryptsetup-libs-2.0.3-3.el7.x86_64 10/85 Verifying : selinux-policy-3.13.1-229.0.3.el7_6.12.noarch 11/85 Verifying : 7:lvm2-2.02.180-10.0.3.el7_6.8.x86_64 12/85 Verifying : 2:container-selinux-2.77-5.el7.noarch 13/85 Verifying : initscripts-9.49.46-1.0.1.el7.x86_64 14/85 Verifying : cryptsetup-python-2.0.3-3.el7.x86_64 15/85 Verifying : libsemanage-python-2.5-14.el7.x86_64 16/85 Verifying : 1:redhat-release-server-7.6-4.0.1.el7.x86_64 17/85 Verifying : 7:oraclelinux-release-7.6-1.0.15.el7.x86_64 18/85 Verifying : device-mapper-persistent-data-0.7.3-3.el7.x86_64 19/85 Verifying : dracut-network-033-554.0.3.el7.x86_64 20/85 Verifying : systemd-sysv-219-62.0.4.el7_6.7.x86_64 21/85 Verifying : containerd-1.2.0-1.0.5.el7.x86_64 22/85 Verifying : policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64 23/85 Verifying : protobuf-c-1.0.2-3.el7.x86_64 24/85 Verifying : dracut-config-rescue-033-554.0.3.el7.x86_64 25/85 Verifying : libselinux-2.5-14.1.el7.x86_64 26/85 Verifying : systemd-219-62.0.4.el7_6.7.x86_64 27/85 Verifying : criu-3.9-5.el7.x86_64 28/85 Verifying : libsemanage-2.5-14.el7.x86_64 29/85 Verifying : systemd-libs-219-62.0.4.el7_6.7.x86_64 30/85 Verifying : libnl3-cli-3.2.28-4.el7.x86_64 31/85 Verifying : systemd-python-219-62.0.4.el7_6.7.x86_64 32/85 Verifying : libselinux-python-2.5-14.1.el7.x86_64 33/85 Verifying : libnet-1.1.6-7.el7.x86_64 34/85 Verifying : libsepol-2.5-10.el7.x86_64 35/85 Verifying : runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64 36/85 Verifying : selinux-policy-targeted-3.13.1-229.0.3.el7_6.12.noarch 37/85 Verifying : libselinux-utils-2.5-14.1.el7.x86_64 38/85 Verifying : dracut-033-554.0.3.el7.x86_64 39/85 Verifying : 7:device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64 40/85 Verifying : 7:device-mapper-1.02.149-10.0.3.el7_6.8.x86_64 41/85 Verifying : libnl3-3.2.28-4.el7.x86_64 42/85 Verifying : docker-cli-18.09.1.ol-1.0.5.el7.x86_64 43/85 Verifying : 7:lvm2-libs-2.02.180-10.0.3.el7_6.8.x86_64 44/85 Verifying : setools-libs-3.3.8-4.el7.x86_64 45/85 Verifying : lz4-1.7.5-2.0.1.el7.x86_64 46/85 Verifying : cryptsetup-2.0.3-3.el7.x86_64 47/85 Verifying : libselinux-utils-2.2.2-6.el7.x86_64 48/85 Verifying : libsemanage-python-2.1.10-16.el7.x86_64 49/85 Verifying : dracut-config-rescue-033-240.0.1.el7.x86_64 50/85 Verifying : systemd-libs-208-20.0.1.el7.x86_64 51/85 Verifying : systemd-sysv-208-20.0.1.el7.x86_64 52/85 Verifying : policycoreutils-2.2.5-15.0.1.el7.x86_64 53/85 Verifying : policycoreutils-python-2.2.5-15.0.1.el7.x86_64 54/85 Verifying : cryptsetup-python-1.6.6-3.el7.x86_64 55/85 Verifying : 7:oraclelinux-release-7.1-1.0.5.el7.x86_64 56/85 Verifying : 7:device-mapper-event-libs-1.02.93-3.el7.x86_64 57/85 Verifying : dracut-033-240.0.1.el7.x86_64 58/85 Verifying : cryptsetup-1.6.6-3.el7.x86_64 59/85 Verifying : setools-libs-3.3.7-46.el7.x86_64 60/85 Verifying : initscripts-9.49.24-1.0.1.el7.x86_64 61/85 Verifying : kmod-14-10.el7.x86_64 62/85 Verifying : systemd-python-208-20.0.1.el7.x86_64 63/85 Verifying : cryptsetup-libs-1.6.6-3.el7.x86_64 64/85 Verifying : dracut-network-033-240.0.1.el7.x86_64 65/85 Verifying : glib2-2.40.0-4.el7.x86_64 66/85 Verifying : libnl3-cli-3.2.21-8.0.1.el7.x86_64 67/85 Verifying : libnl3-3.2.21-8.0.1.el7.x86_64 68/85 Verifying : 7:device-mapper-event-1.02.93-3.el7.x86_64 69/85 Verifying : libselinux-python-2.2.2-6.el7.x86_64 70/85 Verifying : libsemanage-2.1.10-16.el7.x86_64 71/85 Verifying : libseccomp-2.1.1-2.el7.x86_64 72/85 Verifying : libsepol-2.1.9-3.el7.x86_64 73/85 Verifying : 7:lvm2-python-libs-2.02.115-3.el7.x86_64 74/85 Verifying : 7:device-mapper-1.02.93-3.el7.x86_64 75/85 Verifying : selinux-policy-3.13.1-23.0.1.el7.noarch 76/85 Verifying : libselinux-2.2.2-6.el7.x86_64 77/85 Verifying : 1:redhat-release-server-7.1-1.0.2.el7.x86_64 78/85 Verifying : libgudev1-208-20.0.1.el7.x86_64 79/85 Verifying : 7:lvm2-2.02.115-3.el7.x86_64 80/85 Verifying : 7:lvm2-libs-2.02.115-3.el7.x86_64 81/85 Verifying : 7:device-mapper-libs-1.02.93-3.el7.x86_64 82/85 Verifying : device-mapper-persistent-data-0.4.1-2.el7.x86_64 83/85 Verifying : selinux-policy-targeted-3.13.1-23.0.1.el7.noarch 84/85 Verifying : systemd-208-20.0.1.el7.x86_64 85/85 Installed: docker-engine.x86_64 0:18.09.1.ol-1.0.5.el7 Dependency Installed: container-selinux.noarch 2:2.77-5.el7 containerd.x86_64 0:1.2.0-1.0.5.el7 criu.x86_64 0:3.9-5.el7 docker-cli.x86_64 0:18.09.1.ol-1.0.5.el7 libnet.x86_64 0:1.1.6-7.el7 lz4.x86_64 0:1.7.5-2.0.1.el7 protobuf-c.x86_64 0:1.0.2-3.el7 runc.x86_64 0:1.0.0-19.rc5.git4bb1fe4.0.3.el7 Updated: dracut.x86_64 0:033-554.0.3.el7 initscripts.x86_64 0:9.49.46-1.0.1.el7 oraclelinux-release.x86_64 7:7.6-1.0.15.el7 redhat-release-server.x86_64 1:7.6-4.0.1.el7 Dependency Updated: cryptsetup.x86_64 0:2.0.3-3.el7 cryptsetup-libs.x86_64 0:2.0.3-3.el7 cryptsetup-python.x86_64 0:2.0.3-3.el7 device-mapper.x86_64 7:1.02.149-10.0.3.el7_6.8 device-mapper-event.x86_64 7:1.02.149-10.0.3.el7_6.8 device-mapper-event-libs.x86_64 7:1.02.149-10.0.3.el7_6.8 device-mapper-libs.x86_64 7:1.02.149-10.0.3.el7_6.8 device-mapper-persistent-data.x86_64 0:0.7.3-3.el7 dracut-config-rescue.x86_64 0:033-554.0.3.el7 dracut-network.x86_64 0:033-554.0.3.el7 glib2.x86_64 0:2.56.1-4.el7_6 kmod.x86_64 0:20-23.0.1.el7 libgudev1.x86_64 0:219-62.0.4.el7_6.7 libnl3.x86_64 0:3.2.28-4.el7 libnl3-cli.x86_64 0:3.2.28-4.el7 libseccomp.x86_64 0:2.3.1-3.el7 libselinux.x86_64 0:2.5-14.1.el7 libselinux-python.x86_64 0:2.5-14.1.el7 libselinux-utils.x86_64 0:2.5-14.1.el7 libsemanage.x86_64 0:2.5-14.el7 libsemanage-python.x86_64 0:2.5-14.el7 libsepol.x86_64 0:2.5-10.el7 lvm2.x86_64 7:2.02.180-10.0.3.el7_6.8 lvm2-libs.x86_64 7:2.02.180-10.0.3.el7_6.8 lvm2-python-libs.x86_64 7:2.02.180-10.0.3.el7_6.8 policycoreutils.x86_64 0:2.5-29.0.1.el7_6.1 policycoreutils-python.x86_64 0:2.5-29.0.1.el7_6.1 selinux-policy.noarch 0:3.13.1-229.0.3.el7_6.12 selinux-policy-targeted.noarch 0:3.13.1-229.0.3.el7_6.12 setools-libs.x86_64 0:3.3.8-4.el7 systemd.x86_64 0:219-62.0.4.el7_6.7 systemd-libs.x86_64 0:219-62.0.4.el7_6.7 systemd-python.x86_64 0:219-62.0.4.el7_6.7 systemd-sysv.x86_64 0:219-62.0.4.el7_6.7 Complete!
一旦安裝完成,就可以啟動docker服務
[root@localhost soft]# service docker start Redirecting to /bin/systemctl start docker.service [root@localhost soft]# systemctl enable docker [root@localhost soft]# service docker status Redirecting to /bin/systemctl status docker.service 鈼[0m docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/docker.service.d 鈹斺攢docker-sysconfig.conf Active: active (running) since Mon 2019-06-10 23:15:05 CST; 6h left Docs: Main PID: 1452 (dockerd) Memory: 132.2M CGroup: /system.slice/docker.service 鈹溾攢1452 /usr/bin/dockerd --selinux-enabled --storage-driver devicemapper --storage-opt dm.basesize=25G 鈹斺攢2436 containerd --config /var/run/docker/containerd/containerd.toml --log-level info Jun 10 23:15:03 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:03.843382248+08:00" level=info msg="Successfully created filesystem xfs on device docker-253:0-1047242-base" storage-driver=devicemapper Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.076789613+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds" Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.078665673+08:00" level=warning msg="mountpoint for pids not found" Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.079906275+08:00" level=info msg="Loading containers: start." Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.554467519+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to...rred IP address" Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.859786800+08:00" level=info msg="Loading containers: done." Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.959099871+08:00" level=info msg="Docker daemon" commit=c3ab8a8 graphdriver(s)=devicemapper version=18.09.1-ol Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.959938124+08:00" level=info msg="Daemon has completed initialization" Jun 10 23:15:05 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:05.053166130+08:00" level=info msg="API listen on /var/run/docker.sock" Jun 10 23:15:05 localhost.localdomain systemd[1]: Started Docker Application Container Engine. Hint: Some lines were ellipsized, use -l to show in full.
然後可以下載映象檔案
[root@localhost soft]# docker pull mysql/mysql-server:5.7 Trying to pull repository docker.io/mysql/mysql-server ... 5.7: Pulling from docker.io/mysql/mysql-server 35defbf6c365: Pull complete 0fa46ab0f51d: Pull complete f70f5000008c: Pull complete 892ac46af8c0: Pull complete Digest: sha256:ddb046076781a15200d36cb01f8f512431c3481bedebd5e92646d8c617ae212c Status: Downloaded newer image for mysql/mysql-server:5.7 [root@localhost soft]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql/mysql-server 5.7 857eadf53a54 6 weeks ago 258MB
使用Docker來部署MySQL
下載MySQL Server Docker映象檔案
嚴格來說,不需要在單獨的步驟中下載伺服器映象,但是,在建立Docker容器之前執行此步驟可以確保本地映像是最新的。為了下載MySQL社群版映象,執行以下命令:
docker pull mysql/mysql-server:tag
tag是你想要pull映象版本的標識(例如,5.5,5.6,5.7,8.0或最新版本)。如果:tag被忽略,latest標記會被使用並且最新通用可用版本的MySQL社群版本映象將會被下載。網址
列出了所有可用版本資訊.
[root@localhost soft]# docker pull mysql/mysql-server:5.7 Trying to pull repository docker.io/mysql/mysql-server ... 5.7: Pulling from docker.io/mysql/mysql-server 35defbf6c365: Pull complete 0fa46ab0f51d: Pull complete f70f5000008c: Pull complete 892ac46af8c0: Pull complete Digest: sha256:ddb046076781a15200d36cb01f8f512431c3481bedebd5e92646d8c617ae212c Status: Downloaded newer image for mysql/mysql-server:5.7
如果要顯示Docker映象可以執行以下命令:
[root@localhost soft]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql/mysql-server 5.7 857eadf53a54 6 weeks ago 258MB
為了下載MySQL企業版本映象,執行以下命令:
docker pull store/oracle/mysql-enterprise-server:5.7
5.7是我們想要pull的映象版本。MySQL企業版本容器只提供了最新的通用可用版本5.7
啟動MySQL Server例項
為MySQL社群版本伺服器啟動一個新的Docker容器執行以下命令:
[root@localhost ~]# docker run --name=mysql1 -d mysql/mysql-server:5.7 5128014e440f10c557b52e6203445a01c97728e432d0f231c6027bf4b15520bd
為MySQL企業版本伺服器啟動一個新的Docker容器執行以下命令:
docker run --name=mysql1 -d store/oracle/mysql-enterprise-server:tag
--name選項,用來為你的服務容器指定名字(例如mysql1),它是可選項。如果沒有提供容器名,會生成一個隨機容器名。如果之前的docker pull或docker run命令所指定名稱或標記的Docker映象沒有下載,那麼映象現在就會被下載。在下載完成後,開始初始化容器,並且當你執行docker ps命令時容器會出現在正在執行的容器列表中。例如:
[root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5128014e440f mysql/mysql-server:5.7 "/entrypoint.sh mysq鈥 42 seconds ago Up 39 seconds (health: starting) 3306/tcp, 33060/tcp mysql1
IMAGE列的輸出對於MySQL社群版本讀取的值為mysql/mysql-server,對於MySQL企業版本讀取的值為store/oracle/mysql-enterprise-server。
容器初始化可能會花費一些時間。當服務準備好使用時,docker ps命令輸出的STATUS列將從(health: starting)改變為(healthy)。
在上面的docker run命令中-d選項使容器在後臺執行。使用下面的命令可以監控容器的輸出資訊:
[root@localhost ~]# docker logs mysql1 [Entrypoint] MySQL Docker Image 5.7.26-1.1.11 [Entrypoint] No password option specified for new database. [Entrypoint] A random onetime password will be generated. [Entrypoint] Initializing database [Entrypoint] Database initialized Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it. [Entrypoint] GENERATED ROOT PASSWORD: 3z[omLAk4Jaz@sYxDiLYnyPySYfR [Entrypoint] ignoring /docker-entrypoint-initdb.d/* [Entrypoint] Server shut down [Entrypoint] Setting root user as expired. Password will need to be changed before database can be used. [Entrypoint] MySQL init process done. Ready for start up. [Entrypoint] Starting MySQL 5.7.26-1.1.11
一旦初始化完成,命令的輸出將會包含為root使用者生成隨機密碼的資訊,也可以執行下面的命令來檢查密碼:
[root@localhost ~]# docker logs mysql1 2>&1 | grep GENERATED [Entrypoint] GENERATED ROOT PASSWORD: 3z[omLAk4Jaz@sYxDiLYnyPySYfR
在容器中連線MySQL伺服器
一旦服務可以使用後,可以在剛剛啟動的MySQL服務容器中執行mysql客戶端程式並連線到MySQL服務。在剛剛啟動的Docker容器中使用docker exec -it命令來啟動mysql客戶端程式,例如:
[root@localhost ~]# docker exec -it mysql1 mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 107 Server version: 5.7.26 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>
在執行上面的命令時需要輸入root使用者生成的密碼。因為mysql_onetime_password選項預設情況為true(對於MySQL社群版本來說),在mysql客戶端連線到MySQL服務後,必須要透過執行以下命令來修改root使用者的密碼:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; Query OK, 0 rows affected (0.00 sec)
一旦修改密碼後,MySQL服務就可以使用。
容器Shell訪問
為了使用shell訪問你的MySQL伺服器容器,在容器中使用docker exec -it命令來啟動bash shell:
[root@localhost ~]# docker exec -it mysql1 bash bash-4.2#
在啟動bash shell後,在容器中可以執行linux命令,例如,為了檢視容器中的MySQL資料庫的資料目錄中的內容,執行以下命令:
bash-4.2# ls /var/lib/mysql auto.cnf ca.pem client-key.pem ib_logfile0 ibdata1 mysql mysql.sock.lock private_key.pem server-cert.pem sys ca-key.pem client-cert.pem ib_buffer_pool ib_logfile1 ibtmp1 mysql.sock performance_schema public_key.pem server-key.pem
停止與刪除一個MySQL容器
為了停止已經建立的MySQL服務容器執行下面的命令:
[root@localhost ~]# docker stop mysql1 mysql1 [root@localhost ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5128014e440f mysql/mysql-server:5.7 "/entrypoint.sh mysql" 21 hours ago Exited (0) 8 seconds ago mysql1
docker stop將傳送一個SIGTERM訊號給mysqld程式,因此服務將被優雅的關閉。
還可以觀察到當一個容器的主程式(一個MySQL服務容器的主程式為mysqld)被關閉,Docker容器也會自動關閉。
啟動MySQL服務容器:
[root@localhost ~]# docker start mysql1 mysql1 [root@localhost ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5128014e440f mysql/mysql-server:5.7 "/entrypoint.sh mysql" 22 hours ago Up 5 seconds (health: starting) 3306/tcp, 33060/tcp mysql1 [root@localhost ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5128014e440f mysql/mysql-server:5.7 "/entrypoint.sh mysql" 22 hours ago Up 15 seconds (health: starting) 3306/tcp, 33060/tcp mysql1 [root@localhost ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5128014e440f mysql/mysql-server:5.7 "/entrypoint.sh mysql" 22 hours ago Up 21 seconds (health: starting) 3306/tcp, 33060/tcp mysql1 [root@localhost ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5128014e440f mysql/mysql-server:5.7 "/entrypoint.sh mysql" 22 hours ago Up 32 seconds (healthy) 3306/tcp, 33060/tcp mysql1
為了使用單個命令停止與再次啟動MySQL服務容器:
[root@localhost ~]# docker restart mysql1 mysql1 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5128014e440f mysql/mysql-server:5.7 "/entrypoint.sh mysql" 24 hours ago Up 6 seconds (health: starting) 3306/tcp, 33060/tcp mysql1
為了刪除MySQL容器,首先停止容器,然後再使用docker rm命令:
[root@localhost ~]# docker stop mysql1 mysql1 [root@localhost ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5128014e440f mysql/mysql-server:5.7 "/entrypoint.sh mysq1" 24 hours ago Exited (0) 12 seconds ago mysql1 [root@localhost ~]# docker rm mysql1 mysql1 [root@localhost ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
為Docker最佳化MySQL的安裝
MySQL的Docker映像針對程式碼大小進行了最佳化,這意味著它們只包含與大多數在Docker容器中執行MySQL例項的使用者相關的關鍵元件。一個MySQL Docker安裝與常見的非Docker安裝在以下方面不同:
包含的二進位制檔案是有限的:
/usr/bin/my_print_defaults /usr/bin/mysql /usr/bin/mysql_config /usr/bin/mysql_install_db /usr/bin/mysql_tzinfo_to_sql /usr/bin/mysql_upgrade /usr/bin/mysqladmin /usr/bin/mysqlcheck /usr/bin/mysqldump /usr/bin/mysqlpump /usr/sbin/mysqld
所有的二進位制檔案被stripped;它們不包含除錯資訊。
配置MySQL Server
當你啟動MySQL Docker容器時,可以透過docker run命令來傳遞配置選項給服務,例如,對於MySQL社群版本伺服器
docker run --name mysql1 -d mysql/mysql-server:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_col
對於MySQL企業版本伺服器:
docker run --name mysql1 -d store/oracle/mysql-enterprise-server --character-set-server=utf8mb4 --collation-server=utf8mb4_col
命令以utf8mb4作為預設字符集和utf8mb4col作為您的資料庫的預設排序啟動MySQL伺服器。另一種配置MySQL伺服器的方法是準備一個配置檔案,並將其掛載到容器內的伺服器配置檔案的位置。有關詳細資訊,請參閱持久資料和配置更改。
持久資料和配置更改
Docker容器在原則上是臨時的,如果容器被刪除或損壞,任何資料或配置都將丟失(參見討論)。然而,Docker卷提供了一種機制,可以在Docker容器中儲存資料。在初始化時,MySQL伺服器容器為伺服器資料目錄建立Docker卷。執行docker檢查容器命令的JSON輸出有一個掛載鍵,其值提供資料目錄卷的資訊:
[root@localhost ~]# docker inspect mysql1 ... "Mounts": [ { "Type": "volume", "Name": "a74fb4e3348635ddc0b3eb32e3f82b4feb38eeadd8d5b3ae60b4389ab83a86d8", "Source": "/var/lib/docker/volumes/a74fb4e3348635ddc0b3eb32e3f82b4feb38eeadd8d5b3ae60b4389ab83a86d8/_data", "Destination": "/var/lib/mysql", "Driver": "local", "Mode": "", "RW": true, "Propagation": "" } ], ...
輸出顯示原始檔夾
/var/lib/docker/volumes/a74fb4e3348635ddc0b3eb32e3f82b4feb38eeadd8d5b3ae60b4389ab83a86d8/_data將資料持久化到主機上的資料,已經安裝在/var/lib/mysql中,容器內的伺服器資料目錄。
儲存資料的另一種方法是在建立容器時使用 --mount 選項掛載主機目錄。同樣的技術可以用來持久化伺服器的配置。
下面的命令建立一個MySQL伺服器容器,並將資料目錄和伺服器配置檔案繫結在一起:
docker run --name=mysql1 \ --mount type=bind,src=/path-on-host-machine/my.cnf,dst=/etc/my.cnf \ --mount type=bind,src=/path-on-host-machine/datadir,dst=/var/lib/mysql \ -d mysql/mysql-server:tag
配置檔案path-on-host-machine/my.cnf必須存在,同時包含指定的使用者:
[mysqld] user=mysql
path-on-host-machine.datadir目錄必須存在。要發生伺服器初始化,目錄必須是空的。您還可以安裝一個帶有資料的目錄,並使用它啟動伺服器;但是,您必須確保啟動Docker容器,其配置與建立資料的伺服器具有相同的配置,並且啟動容器時所需的任何主機檔案或目錄都被安裝。
執行額外的初始化指令碼
如果您想在建立後立即在資料庫上執行任何.sh或.sql指令碼,您可以將它們放入主機目錄中,然後mount目錄在/docker-entrypoint-initdb.d
docker run --name=mysql1 \ --mount type=bind,src=/path-on-host-machine/scripts/,dst=/docker-entrypoint-initdb.d/ \ -d mysql/mysql-server:tag
對於MySQL企業版本伺服器容器:
docker run --name=mysql1 \ --mount type=bind,src=/path-on-host-machine/scripts/,dst=/docker-entrypoint-initdb.d/ \ -d store/oracle/mysql-enterprise-server:tag
從另一個Docker容器中的應用程式連線到MySQL
透過建立一個Docker網路,你可以讓多個Docker容器相互通訊,這樣,在另一個Docker容器中的客戶端應用程式就可以在伺服器容器中訪問MySQL伺服器。首先,建立一個Docker網路:
docker network create my-custom-net
然後,當您建立並啟動伺服器和客戶端容器時,使用-network選項將它們放在您建立的網路上。例如:
docker run --name=mysql1 --network=my-custom-net -d mysql/mysql-server docker run --name=myapp1 --network=my-custom-net -d myapp
當使用MySQL企業版本伺服器容器:
docker run --name=mysql1 --network=my-custom-net -d store/oracle/mysql-enterprise-server docker run --name=myapp1 --network=my-custom-net -d myapp
myapp1容器隨後可以與mysql1主機連線到mysql1容器,反之亦然,因為Docker會自動為給定的容器名稱設定一個DNS。在下面的例子中,我們從myapp1容器中執行mysql客戶端,以便在自己的容器中連線主機mysql1:
docker exec -it myapp1 mysql --host=mysql1 --user=myuser --password
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2649372/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- yum install mysql5.7MySql
- Docker 部署 mysql 5.7DockerMySql
- Docker 安裝 Mysql 5.7DockerMySql
- 44_docker-compose_mysql5.7DockerMySql
- 安裝MySQL5.7報錯:The action ‘Install’ for product ‘MySQL Server 5.7.19’ failed.MySqlServerAI
- CentOS7利用docker安裝MySQL5.7CentOSDockerMySql
- Docker安裝LNMP-ubuntu18.04+nginx1.14+mysql5.7+php7.3DockerLNMPUbuntuNginxMySqlPHP
- Mysql 5.7.21 install for LinuxMySqlLinux
- Mysql 5.7.22 install for windowsMySqlWindows
- Install Docker CE for Ubuntu 18.04 LTSDockerUbuntu
- Steps to install Docker on Manjaro 16.10--轉DockerJAR
- MySQL 5.7 叢集搭建MySql
- MySQL5.7 多例項MySql
- mysql5.7MHA配置MySql
- MySQL:5.6 升級 5.7MySql
- MySQL 5.7的角色功能MySql
- mysql 5.7主從配置MySql
- MySQL 5.7 InnoDB Tablespace EncryptionMySql
- Mysql 5.7 MHA 高可用MySql
- [Mysql]Mysql5.7並行複製MySql並行
- CentOS 7 安裝 MySQL 5.7CentOSMySql
- CentOS 7 - 安裝MySQL 5.7CentOSMySql
- MySQL5.7: sql script demoMySql
- MySQL 5.7 並行複製MySql並行
- centos安裝mysql5.7CentOSMySql
- mysql 5.7 虛擬列功能MySql
- mysql5.7 安裝教程MySql
- Linux下安裝MySQL 5.7LinuxMySql
- Linux 7 安裝Mysql 5.7LinuxMySql
- MySQL5.7 Waiting FOR TABLE FLUSHMySqlAI
- MySQL 5.7 升級到 8.0MySql
- MySQL 5.7配置SSL連線MySql
- MySQL 5.7:desc order by反向定位MySql
- MySQL 5.7並行複製MySql並行
- mysql 5.7半同步複製MySql
- MySQL基礎之MySQL 5.7 新增配置MySql
- MySQL5.7 Unable to find a match: MySQL-community-serverMySqlUnityServer
- mysql5.7 慢日誌配置MySql