Centos7安装docker、nginx、拉取Java环境、拉取Mysql5.7

1、如果已安装过docker,首先卸载它们以及相关的依赖项。

$ sudo yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest \docker
docker-latest-logrotate
docker-logrotate
docker-engine
2、安装yum-utils软件包 并设置下载所去的仓库。
[root ~]# sudo yum install -y yum-utils
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/7): epel/x86_64/group_gz | 95 kB 00:00:00
(2/7): base/7/x86_64/group_gz | 153 kB 00:00:00
(3/7): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(4/7): extras/7/x86_64/primary_db | 224 kB 00:00:00
(5/7): base/7/x86_64/primary_db | 6.1 MB 00:00:00
(6/7): epel/x86_64/primary_db | 6.9 MB 00:00:00
(7/7): updates/7/x86_64/primary_db | 5.6 MB 00:00:00
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> 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 libxml2-python.x86_64 0:2.9.1-6.el7.5 will be installed
--> Processing Dependency: libxml2 = 2.9.1-6.el7.5 for package: libxml2-python-2.9.1-6.el7.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 libxml2.x86_64 0:2.9.1-6.el7_2.3 will be updated
---> Package libxml2.x86_64 0:2.9.1-6.el7.5 will be an update
---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

'===========================================================================================================
Package Arch Version Repository Size
'===========================================================================================================
Installing:
yum-utils noarch 1.1.31-54.el7_8 base 122 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7.5 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Updating for dependencies:
libxml2 x86_64 2.9.1-6.el7.5 base 668 k

Transaction Summary
'===========================================================================================================
Install 1 Package (+3 Dependent packages)
Upgrade ( 1 Dependent package)

Total download size: 1.5 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/5): libxml2-python-2.9.1-6.el7.5.x86_64.rpm | 247 kB 00:00:00
(2/5): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:00
(3/5): libxml2-2.9.1-6.el7.5.x86_64.rpm | 668 kB 00:00:00
(4/5): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00
(5/5): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00
'-----------------------------------------------------------------------------------------------------------
Total 7.0 MB/s | 1.5 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : libxml2-2.9.1-6.el7.5.x86_64 1/6
Installing : libxml2-python-2.9.1-6.el7.5.x86_64 2/6
Installing : python-chardet-2.2.1-3.el7.noarch 3/6
Installing : python-kitchen-1.1.1-5.el7.noarch 4/6
Installing : yum-utils-1.1.31-54.el7_8.noarch 5/6
Cleanup : libxml2-2.9.1-6.el7_2.3.x86_64 6/6
Verifying : libxml2-python-2.9.1-6.el7.5.x86_64 1/6
Verifying : python-chardet-2.2.1-3.el7.noarch 2/6
Verifying : python-kitchen-1.1.1-5.el7.noarch 3/6
Verifying : yum-utils-1.1.31-54.el7_8.noarch 4/6
Verifying : libxml2-2.9.1-6.el7.5.x86_64 5/6
Verifying : libxml2-2.9.1-6.el7_2.3.x86_64 6/6

Installed:
yum-utils.noarch 0:1.1.31-54.el7_8

Dependency Installed:
libxml2-python.x86_64 0:2.9.1-6.el7.5 python-chardet.noarch 0:2.2.1-3.el7
python-kitchen.noarch 0:1.1.1-5.el7

Dependency Updated:
libxml2.x86_64 0:2.9.1-6.el7.5

Complete!
(走到这里,如果没有错误说明这步已经安装完成了)
[root ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
(这里是指定的阿里仓库,也可以指定中央仓库:yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo)
Loaded plugins: fastestmirror
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@izbp1enc035p71m8y624gwz ~]# sudo yum install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror
docker-ce-stable | 3.5 kB 00:00:00
(1/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/7/x86_64/primary_db | 55 kB 00:00:02
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.4.3-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.4.3-3.1.el7.x86_64
--> Processing Dependency: libseccomp for package: containerd.io-1.4.3-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.3-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.3-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.3-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.3-3.el7 will be installed
--> 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-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package docker-ce-rootless-extras.x86_64 0:20.10.3-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.3-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.3-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 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 policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: policycoreutils = 2.5-34.el7 for package: policycoreutils-python-2.5-34.el7.x86_64
--> 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: 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-102.el7_3.16 will be updated
---> Package selinux-policy.noarch 0:3.13.1-268.el7_9.2 will be an update
--> Processing Dependency: libsemanage >= 2.5-13 for package: selinux-policy-3.13.1-268.el7_9.2.noarch
---> Package selinux-policy-targeted.noarch 0:3.13.1-102.el7_3.16 will be updated
---> Package selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2 will be an update
---> 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
--> Processing Dependency: audit-libs(x86-64) = 2.8.5-4.el7 for package: audit-libs-python-2.8.5-4.el7.x86_64
---> 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 libsemanage.x86_64 0:2.5-5.1.el7_3 will be updated
---> Package libsemanage.x86_64 0:2.5-14.el7 will be an update
--> Processing Dependency: libsepol >= 2.5-10 for package: libsemanage-2.5-14.el7.x86_64
--> Processing Dependency: libselinux >= 2.5-14 for package: libsemanage-2.5-14.el7.x86_64
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package policycoreutils.x86_64 0:2.5-11.el7_3 will be updated
---> Package policycoreutils.x86_64 0:2.5-34.el7 will be an update
--> Processing Dependency: libselinux-utils >= 2.5-14 for package: policycoreutils-2.5-34.el7.x86_64
---> 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
--> Running transaction check
---> Package audit-libs.x86_64 0:2.6.5-3.el7_3.1 will be updated
--> Processing Dependency: audit-libs(x86-64) = 2.6.5-3.el7_3.1 for package: audit-2.6.5-3.el7_3.1.x86_64
---> Package audit-libs.x86_64 0:2.8.5-4.el7 will be an update
---> Package libselinux.x86_64 0:2.5-6.el7 will be updated
--> Processing Dependency: libselinux(x86-64) = 2.5-6.el7 for package: libselinux-python-2.5-6.el7.x86_64
---> Package libselinux.x86_64 0:2.5-15.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.5-6.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-15.el7 will be an update
---> Package libsepol.x86_64 0:2.5-6.el7 will be updated
---> Package libsepol.x86_64 0:2.5-10.el7 will be an update
--> Running transaction check
---> Package audit.x86_64 0:2.6.5-3.el7_3.1 will be updated
---> Package audit.x86_64 0:2.8.5-4.el7 will be an update
---> Package libselinux-python.x86_64 0:2.5-6.el7 will be updated
---> Package libselinux-python.x86_64 0:2.5-15.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

'===========================================================================================================
Package Arch Version Repository Size
'===========================================================================================================
Installing:
containerd.io x86_64 1.4.3-3.1.el7 docker-ce-stable 33 M
docker-ce x86_64 3:20.10.3-3.el7 docker-ce-stable 27 M
docker-ce-cli x86_64 1:20.10.3-3.el7 docker-ce-stable 33 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
docker-ce-rootless-extras x86_64 20.10.3-3.el7 docker-ce-stable 9.0 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
libsemanage-python x86_64 2.5-14.el7 base 113 k
policycoreutils-python x86_64 2.5-34.el7 base 457 k
python-IPy noarch 0.75-6.el7 base 32 k
setools-libs x86_64 3.3.8-4.el7 base 620 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
Updating for dependencies:
audit x86_64 2.8.5-4.el7 base 256 k
audit-libs x86_64 2.8.5-4.el7 base 102 k
libselinux x86_64 2.5-15.el7 base 162 k
libselinux-python x86_64 2.5-15.el7 base 236 k
libselinux-utils x86_64 2.5-15.el7 base 151 k
libsemanage x86_64 2.5-14.el7 base 151 k
libsepol x86_64 2.5-10.el7 base 297 k
policycoreutils x86_64 2.5-34.el7 base 917 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

Transaction Summary
'===========================================================================================================
Install 3 Packages (+13 Dependent packages)
Upgrade ( 10 Dependent packages)

Total download size: 113 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/26): audit-libs-2.8.5-4.el7.x86_64.rpm | 102 kB 00:00:00
(2/26): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(3/26): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
(4/26): audit-2.8.5-4.el7.x86_64.rpm | 256 kB 00:00:00
(5/26): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.3-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-20.10.3-3.el7.x86_64.rpm is not installed
(6/26): docker-ce-20.10.3-3.el7.x86_64.rpm | 27 MB 00:00:04
(7/26): containerd.io-1.4.3-3.1.el7.x86_64.rpm | 33 MB 00:00:06
(8/26): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(9/26): libseccomp-2.3.1-4.el7.x86_64.rpm | 56 kB 00:00:00
(10/26): libselinux-2.5-15.el7.x86_64.rpm | 162 kB 00:00:00
(11/26): libselinux-python-2.5-15.el7.x86_64.rpm | 236 kB 00:00:00
(12/26): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(13/26): libselinux-utils-2.5-15.el7.x86_64.rpm | 151 kB 00:00:00
(14/26): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(15/26): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(16/26): libsemanage-2.5-14.el7.x86_64.rpm | 151 kB 00:00:00
(17/26): libsepol-2.5-10.el7.x86_64.rpm | 297 kB 00:00:00
(18/26): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
(19/26): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(20/26): policycoreutils-2.5-34.el7.x86_64.rpm | 917 kB 00:00:00
(21/26): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
(22/26): selinux-policy-3.13.1-268.el7_9.2.noarch.rpm | 498 kB 00:00:00
(23/26): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(24/26): selinux-policy-targeted-3.13.1-268.el7_9.2.noarch.rpm | 7.0 MB 00:00:00
(25/26): docker-ce-rootless-extras-20.10.3-3.el7.x86_64.rpm | 9.0 MB 00:00:01
(26/26): docker-ce-cli-20.10.3-3.el7.x86_64.rpm | 33 MB 00:00:05
'-----------------------------------------------------------------------------------------------------------
Total 11 MB/s | 113 MB 00:00:10
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
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/36
Updating : libselinux-2.5-15.el7.x86_64 2/36
Updating : audit-libs-2.8.5-4.el7.x86_64 3/36
Updating : libsemanage-2.5-14.el7.x86_64 4/36
Installing : libseccomp-2.3.1-4.el7.x86_64 5/36
Updating : libselinux-utils-2.5-15.el7.x86_64 6/36
Updating : policycoreutils-2.5-34.el7.x86_64 7/36
Updating : selinux-policy-3.13.1-268.el7_9.2.noarch 8/36
Installing : libcgroup-0.41-21.el7.x86_64 9/36
Updating : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch 10/36
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 11/36
Installing : libsemanage-python-2.5-14.el7.x86_64 12/36
Installing : audit-libs-python-2.8.5-4.el7.x86_64 13/36
Installing : setools-libs-3.3.8-4.el7.x86_64 14/36
Updating : libselinux-python-2.5-15.el7.x86_64 15/36
Installing : 1:docker-ce-cli-20.10.3-3.el7.x86_64 16/36
Installing : fuse3-libs-3.6.1-4.el7.x86_64 17/36
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 18/36
Installing : python-IPy-0.75-6.el7.noarch 19/36
Installing : checkpolicy-2.5-8.el7.x86_64 20/36
Installing : policycoreutils-python-2.5-34.el7.x86_64 21/36
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 22/36
setsebool: SELinux is disabled.
Installing : containerd.io-1.4.3-3.1.el7.x86_64 23/36
Installing : docker-ce-rootless-extras-20.10.3-3.el7.x86_64 24/36
Installing : 3:docker-ce-20.10.3-3.el7.x86_64 25/36
Updating : audit-2.8.5-4.el7.x86_64 26/36
Cleanup : selinux-policy-targeted-3.13.1-102.el7_3.16.noarch 27/36
Cleanup : selinux-policy-3.13.1-102.el7_3.16.noarch 28/36
Cleanup : policycoreutils-2.5-11.el7_3.x86_64 29/36
Cleanup : libsemanage-2.5-5.1.el7_3.x86_64 30/36
Cleanup : libselinux-utils-2.5-6.el7.x86_64 31/36
Cleanup : libselinux-python-2.5-6.el7.x86_64 32/36
Cleanup : libselinux-2.5-6.el7.x86_64 33/36
Cleanup : audit-2.6.5-3.el7_3.1.x86_64 34/36
Cleanup : audit-libs-2.6.5-3.el7_3.1.x86_64 35/36
Cleanup : libsepol-2.5-6.el7.x86_64 36/36
Verifying : 3:docker-ce-20.10.3-3.el7.x86_64 1/36
Verifying : libselinux-2.5-15.el7.x86_64 2/36
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 3/36
Verifying : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch 4/36
Verifying : audit-libs-2.8.5-4.el7.x86_64 5/36
Verifying : checkpolicy-2.5-8.el7.x86_64 6/36
Verifying : policycoreutils-2.5-34.el7.x86_64 7/36
Verifying : python-IPy-0.75-6.el7.noarch 8/36
Verifying : libseccomp-2.3.1-4.el7.x86_64 9/36
Verifying : libselinux-utils-2.5-15.el7.x86_64 10/36
Verifying : policycoreutils-python-2.5-34.el7.x86_64 11/36
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 12/36
Verifying : setools-libs-3.3.8-4.el7.x86_64 13/36
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 14/36
Verifying : audit-2.8.5-4.el7.x86_64 15/36
Verifying : libsemanage-python-2.5-14.el7.x86_64 16/36
Verifying : libsemanage-2.5-14.el7.x86_64 17/36
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 18/36
Verifying : libsepol-2.5-10.el7.x86_64 19/36
Verifying : libselinux-python-2.5-15.el7.x86_64 20/36
Verifying : selinux-policy-3.13.1-268.el7_9.2.noarch 21/36
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 22/36
Verifying : containerd.io-1.4.3-3.1.el7.x86_64 23/36
Verifying : docker-ce-rootless-extras-20.10.3-3.el7.x86_64 24/36
Verifying : 1:docker-ce-cli-20.10.3-3.el7.x86_64 25/36
Verifying : libcgroup-0.41-21.el7.x86_64 26/36
Verifying : selinux-policy-3.13.1-102.el7_3.16.noarch 27/36
Verifying : libselinux-python-2.5-6.el7.x86_64 28/36
Verifying : libselinux-utils-2.5-6.el7.x86_64 29/36
Verifying : policycoreutils-2.5-11.el7_3.x86_64 30/36
Verifying : audit-2.6.5-3.el7_3.1.x86_64 31/36
Verifying : libsepol-2.5-6.el7.x86_64 32/36
Verifying : selinux-policy-targeted-3.13.1-102.el7_3.16.noarch 33/36
Verifying : libsemanage-2.5-5.1.el7_3.x86_64 34/36
Verifying : libselinux-2.5-6.el7.x86_64 35/36
Verifying : audit-libs-2.6.5-3.el7_3.1.x86_64 36/36

Installed:
containerd.io.x86_64 0:1.4.3-3.1.el7 docker-ce.x86_64 3:20.10.3-3.el7
docker-ce-cli.x86_64 1:20.10.3-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 docker-ce-rootless-extras.x86_64 0:20.10.3-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
libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7
python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
slirp4netns.x86_64 0:0.4.3-4.el7_8

Dependency Updated:
audit.x86_64 0:2.8.5-4.el7 audit-libs.x86_64 0:2.8.5-4.el7
libselinux.x86_64 0:2.5-15.el7 libselinux-python.x86_64 0:2.5-15.el7
libselinux-utils.x86_64 0:2.5-15.el7 libsemanage.x86_64 0:2.5-14.el7
libsepol.x86_64 0:2.5-10.el7 policycoreutils.x86_64 0:2.5-34.el7
selinux-policy.noarch 0:3.13.1-268.el7_9.2 selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2

Complete!
(走到这里,如果没有错误说明这步已经安装完成了)
3、启动docker
[root ~]# sudo systemctl start docker
设置加速,为了yum下载速度快:
[root ~]# sudo mkdir -p /etc/docker
[root ~]# sudo tee /etc/docker/daemon.json <<-'EOF'
> {
> "registry-mirrors": ["https://501cm43k.mirror.aliyuncs.com"]
> }
> EOF
{
"registry-mirrors": ["https://501cm43k.mirror.aliyuncs.com"]
}
[root ~]# sudo systemctl daemon-reload
[root ~]# sudo systemctl restart docker
设置为服务开机自启动:
[root ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
查看是否成功:
[root ~]# systemctl list-unit-files |grep docker
docker.service enabled
docker.socket disabled


下面是安装并运行nginx,安装nginx时,可以直接将容器里的nginx的配置映射出来
首先创建一个临时的容器:
[root ~]# docker run --name nginx -d nginx
d7a234d3727f84043e020927b04f0d74981f7e7c0e91b18040f129668c6e5350
将html拷贝到自己的路径下:
[root ~]# docker cp nginx:/usr/share/nginx/html /usr/nginx/
将nginx.conf拷贝到自己的路径下:
[root ~]# docker cp nginx:/etc/nginx/nginx.conf /usr/nginx/config/nginx.conf
同理将conf.d拷贝到自己的路径下:
[root ~]# docker cp nginx:/etc/nginx/conf.d /usr/nginx/
删除临时的nginx容器:
[root ~]# docker rm -f nginx
nginx
重新直接创建并直接映射(也可以直接将自己的配置放到自己的目录,这样上述几步均可省略,上述采用的是默认配置)
[root ~]# docker run -it -d --name nginx -p 8001:80 -v /usr/nginx/config/nginx.conf:/etc/nginx/nginx.conf -v /usr/nginx/html:/usr/share/nginx/html -v /docker/nginx/conf.d:/etc/nginx/conf.d -v /docker/nginx/logs:/var/log/nginx nginx
709316edf68d9d9ddbe20b1f3994b10d3a2429264ef1a4d3cb8863722a0d96a7
注:docker run:表示创建容器的命令,-i表示运行容器,-t表示容器启动后会进入命令行,-d:在run后面加上-d参数,则会创建一个守护式容器在后台运行(这样创建容器后不会自动登录容器,如果只加-i -t两个参数,创建后就会自动进去容器),--name命名,-p是宿主机端口:容器对应的端口,第一个-v 宿主机是.conf的路径:官方文档中固定的路径,第二个路径是打包后的Vue前端文件路径:官方固定的路径
(注意:/docker/nginx/conf.d:/etc/nginx/conf.d 后面这个路径下的default.conf一定要在nginx.conf的最后一个incloud所包含的路径下,否则找不到这个文件)

查看是否启动:
[root ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
709316edf68d nginx "/docker-entrypoint.…" 11 seconds ago Up 10 seconds 0.0.0.0:8001->80/tcp nginx
[root ~]#


拉取Java8:
[root ~]# docker pull java:8
8: Pulling from library/java
5040bd298390: Pull complete
fce5728aad85: Pull complete
76610ec20bf5: Pull complete
60170fec2151: Pull complete
e98f73de8f0d: Pull complete
11f7af24ed9c: Pull complete
49e2d6393f32: Pull complete
bb9cdec9c7f3: Pull complete
Digest: sha256:c1ff613e8ba25833d2e1940da0940c3824f03f802c449f3d1815a66b7f8c0e9d
Status: Downloaded newer image for java:8
docker.io/library/java:8
查看是否成功:
[root ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest f6d0b4767a6c 5 weeks ago 133MB
java 8 d23bdf5b1b1b 4 years ago 643MB
[root ~]#


拉取Mysql5.7:
[root ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
a076a628af6f: Already exists
f6c208f3f991: Pull complete
88a9455a9165: Pull complete
406c9b8427c6: Pull complete
7c88599c0b25: Pull complete
25b5c6debdaf: Pull complete
43a5816f1617: Pull complete
1831ac1245f4: Pull complete
37677b8c1f79: Pull complete
27e4ac3b0f6e: Pull complete
7227baa8c445: Pull complete
Digest: sha256:b3d1eff023f698cd433695c9506171f0d08a8f92a0c8063c1a4d9db9a55808df
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
[root ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7 a70d36bc331a 4 weeks ago 449MB
nginx latest f6d0b4767a6c 5 weeks ago 133MB
java 8 d23bdf5b1b1b 4 years ago 643MB
创建MySQL容器:
[root ~]# docker run -id --name=mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7
20ebeb5bab561983a2bdc3bd11ed99ee1d3e9006770533d9189bcf1194a94dd4
进入容器并登录一下:
[root ~]# docker exec -it mysql /bin/bash
root@20ebeb5bab56:/# mysql -u root -p
**Enter password: **
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.33 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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>
测试连接:

posted @ 2021-02-19 14:29  惜别常忆丶  阅读(632)  评论(0)    收藏  举报