官方文档
Docker安装
[root@localhost cps]# sudo yum install -y yum-utils
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 2755.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 164 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:17 2024 - 00:33 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:17 2024 - 00:35 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:17 2024 - 00:37 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:17 2024 - 00:39 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:17 2024 - 00:41 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:17 2024 - 00:43 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:17 2024 - 00:45 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:17 2024 - 00:47 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:17 2024 - 00:49 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 00:51 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 00:53 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 00:55 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 00:57 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 00:59 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:01 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:03 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:05 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:07 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:09 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:11 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:13 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:15 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:17 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:19 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:21 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:23 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:25 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:27 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:29 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:31 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:33 ago
State : Sleeping, pid: 2755
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 171 M RSS (1.5 GB VSZ)
Started: Mon May 6 23:20:50 2024 - 01:35 ago
State : Sleeping, pid: 2755
^Z
[1]+ Stopped sudo yum install -y yum-utils
[root@localhost cps]# kill 2755
[root@localhost cps]# sudo yum install -y yum-utils
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* extras: mirrors.bupt.edu.cn
* updates: mirrors.bupt.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-45.el7 will be updated
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
yum-utils noarch 1.1.31-54.el7_8 base 122 k
Transaction Summary
================================================================================
Upgrade 1 Package
Total download size: 122 k
Downloading packages:
No Presto metadata available for base
warning: /var/cache/yum/x86_64/7/base/packages/yum-utils-1.1.31-54.el7_8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for yum-utils-1.1.31-54.el7_8.noarch.rpm is not installed
yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-5.1804.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
Updating : yum-utils-1.1.31-54.el7_8.noarch 1/2
Cleanup : yum-utils-1.1.31-45.el7.noarch 2/2
Verifying : yum-utils-1.1.31-54.el7_8.noarch 1/2
Verifying : yum-utils-1.1.31-45.el7.noarch 2/2
Updated:
yum-utils.noarch 0:1.1.31-54.el7_8
Complete!
[root@localhost cps]# sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@localhost cps]# sudo yum install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* extras: mirrors.bupt.edu.cn
* updates: mirrors.bupt.edu.cn
docker-ce-stable | 3.5 kB 00:00
(1/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00
(2/2): docker-ce-stable/7/x86_64/primary_db | 147 kB 00:01
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.31-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.6.31-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:26.1.1-1.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-26.1.1-1.el7.x86_64
---> Package docker-ce-cli.x86_64 1:26.1.1-1.el7 will be installed
--> Processing Dependency: docker-buildx-plugin for package: 1:docker-ce-cli-26.1.1-1.el7.x86_64
--> Processing Dependency: docker-compose-plugin for package: 1:docker-ce-cli-26.1.1-1.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: selinux-policy-targeted >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: selinux-policy-base >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: selinux-policy >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package docker-buildx-plugin.x86_64 0:0.14.0-1.el7 will be installed
---> Package docker-ce-rootless-extras.x86_64 0:26.1.1-1.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-26.1.1-1.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-26.1.1-1.el7.x86_64
---> Package docker-compose-plugin.x86_64 0:2.27.0-1.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 selinux-policy.noarch 0:3.13.1-192.el7 will be updated
---> Package selinux-policy.noarch 0:3.13.1-268.el7_9.2 will be an update
--> Processing Dependency: policycoreutils >= 2.5-24 for package: selinux-policy-3.13.1-268.el7_9.2.noarch
--> 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-192.el7 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 fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libsemanage.x86_64 0:2.5-11.el7 will be updated
--> Processing Dependency: libsemanage = 2.5-11.el7 for package: libsemanage-python-2.5-11.el7.x86_64
---> 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 policycoreutils.x86_64 0:2.5-22.el7 will be updated
--> Processing Dependency: policycoreutils = 2.5-22.el7 for package: policycoreutils-python-2.5-22.el7.x86_64
---> 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
--> Running transaction check
---> Package libselinux.x86_64 0:2.5-12.el7 will be updated
--> Processing Dependency: libselinux(x86-64) = 2.5-12.el7 for package: libselinux-python-2.5-12.el7.x86_64
---> Package libselinux.x86_64 0:2.5-15.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.5-12.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-15.el7 will be an update
---> Package libsemanage-python.x86_64 0:2.5-11.el7 will be updated
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be an update
---> Package libsepol.x86_64 0:2.5-8.1.el7 will be updated
---> Package libsepol.x86_64 0:2.5-10.el7 will be an update
---> Package policycoreutils-python.x86_64 0:2.5-22.el7 will be updated
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be an update
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Running transaction check
---> Package libselinux-python.x86_64 0:2.5-12.el7 will be updated
---> Package libselinux-python.x86_64 0:2.5-15.el7 will be an update
---> Package setools-libs.x86_64 0:3.3.8-2.el7 will be updated
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
containerd.io x86_64 1.6.31-3.1.el7 docker-ce-stable 35 M
docker-ce x86_64 3:26.1.1-1.el7 docker-ce-stable 27 M
docker-ce-cli x86_64 1:26.1.1-1.el7 docker-ce-stable 15 M
Installing for dependencies:
container-selinux noarch 2:2.119.2-1.911c772.el7_8
extras 40 k
docker-buildx-plugin x86_64 0.14.0-1.el7 docker-ce-stable 14 M
docker-ce-rootless-extras x86_64 26.1.1-1.el7 docker-ce-stable 9.4 M
docker-compose-plugin x86_64 2.27.0-1.el7 docker-ce-stable 13 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
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
Updating for dependencies:
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
libsemanage-python x86_64 2.5-14.el7 base 113 k
libsepol x86_64 2.5-10.el7 base 297 k
policycoreutils x86_64 2.5-34.el7 base 917 k
policycoreutils-python x86_64 2.5-34.el7 base 457 k
selinux-policy noarch 3.13.1-268.el7_9.2 updates 498 k
selinux-policy-targeted noarch 3.13.1-268.el7_9.2 updates 7.0 M
setools-libs x86_64 3.3.8-4.el7 base 620 k
Transaction Summary
================================================================================
Install 3 Packages (+ 7 Dependent packages)
Upgrade ( 11 Dependent packages)
Total size: 124 M
Total download size: 117 M
Is this ok [y/d/N]: Y
Downloading packages:
No Presto metadata available for base
No Presto metadata available for updates
(1/17): container-selinux-2.119.2-1.911c772.el7_8.noarch.r | 40 kB 00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-buildx-plugin-0.14.0-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-buildx-plugin-0.14.0-1.el7.x86_64.rpm is not installed
(2/17): docker-buildx-plugin-0.14.0-1.el7.x86_64.rpm | 14 MB 00:33
(3/17): containerd.io-1.6.31-3.1.el7.x86_64.rpm | 35 MB 01:38
(4/17): docker-ce-26.1.1-1.el7.x86_64.rpm | 27 MB 01:31
(5/17): docker-ce-rootless-extras-26.1.1-1.el7.x86_64.rpm | 9.4 MB 00:17
(6/17): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00
(7/17): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00
(8/17): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00
(9/17): libselinux-python-2.5-15.el7.x86_64.rpm | 236 kB 00:00
(10/17): libsepol-2.5-10.el7.x86_64.rpm | 297 kB 00:00
(11/17): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00
(12/17): policycoreutils-2.5-34.el7.x86_64.rpm | 917 kB 00:00
(13/17): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00
(14/17): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00
(15/17): selinux-policy-3.13.1-268.el7_9.2.noarch.rpm | 498 kB 00:00
(16/17): docker-compose-plugin-2.27.0-1.el7.x86_64.rpm | 13 MB 00:25
(17/17): docker-ce-cli-26.1.1-1.el7.x86_64.rpm | 15 MB 00:02:01
----------------------------------------------------------------------------------------------------------------------------------------
Total 545 kB/s | 117 MB 00:03:39
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/32
Updating : libselinux-2.5-15.el7.x86_64 2/32
Updating : libsemanage-2.5-14.el7.x86_64 3/32
Updating : libselinux-utils-2.5-15.el7.x86_64 4/32
Updating : policycoreutils-2.5-34.el7.x86_64 5/32
Updating : selinux-policy-3.13.1-268.el7_9.2.noarch 6/32
Updating : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch 7/32
Updating : libsemanage-python-2.5-14.el7.x86_64 8/32
Updating : libselinux-python-2.5-15.el7.x86_64 9/32
Updating : setools-libs-3.3.8-4.el7.x86_64 10/32
Updating : policycoreutils-python-2.5-34.el7.x86_64 11/32
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 12/32
Installing : containerd.io-1.6.31-3.1.el7.x86_64 13/32
Installing : docker-compose-plugin-2.27.0-1.el7.x86_64 14/32
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 15/32
Installing : fuse3-libs-3.6.1-4.el7.x86_64 16/32
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 17/32
Installing : docker-buildx-plugin-0.14.0-1.el7.x86_64 18/32
Installing : 1:docker-ce-cli-26.1.1-1.el7.x86_64 19/32
Installing : 3:docker-ce-26.1.1-1.el7.x86_64 20/32
Installing : docker-ce-rootless-extras-26.1.1-1.el7.x86_64 21/32
Cleanup : selinux-policy-targeted-3.13.1-192.el7.noarch 22/32
Cleanup : policycoreutils-python-2.5-22.el7.x86_64 23/32
Cleanup : selinux-policy-3.13.1-192.el7.noarch 24/32
Cleanup : policycoreutils-2.5-22.el7.x86_64 25/32
Cleanup : libselinux-utils-2.5-12.el7.x86_64 26/32
Cleanup : setools-libs-3.3.8-2.el7.x86_64 27/32
Cleanup : libselinux-python-2.5-12.el7.x86_64 28/32
Cleanup : libsemanage-python-2.5-11.el7.x86_64 29/32
Cleanup : libsemanage-2.5-11.el7.x86_64 30/32
Cleanup : libselinux-2.5-12.el7.x86_64 31/32
Cleanup : libsepol-2.5-8.1.el7.x86_64 32/32
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 1/32
Verifying : docker-buildx-plugin-0.14.0-1.el7.x86_64 2/32
Verifying : libselinux-2.5-15.el7.x86_64 3/32
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 4/32
Verifying : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch 5/32
Verifying : 3:docker-ce-26.1.1-1.el7.x86_64 6/32
Verifying : policycoreutils-2.5-34.el7.x86_64 7/32
Verifying : libselinux-utils-2.5-15.el7.x86_64 8/32
Verifying : policycoreutils-python-2.5-34.el7.x86_64 9/32
Verifying : containerd.io-1.6.31-3.1.el7.x86_64 10/32
Verifying : 1:docker-ce-cli-26.1.1-1.el7.x86_64 11/32
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 12/32
Verifying : libsemanage-python-2.5-14.el7.x86_64 13/32
Verifying : libsemanage-2.5-14.el7.x86_64 14/32
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 15/32
Verifying : libsepol-2.5-10.el7.x86_64 16/32
Verifying : docker-compose-plugin-2.27.0-1.el7.x86_64 17/32
Verifying : libselinux-python-2.5-15.el7.x86_64 18/32
Verifying : selinux-policy-3.13.1-268.el7_9.2.noarch 19/32
Verifying : docker-ce-rootless-extras-26.1.1-1.el7.x86_64 20/32
Verifying : setools-libs-3.3.8-4.el7.x86_64 21/32
Verifying : libsemanage-python-2.5-11.el7.x86_64 22/32
Verifying : libsemanage-2.5-11.el7.x86_64 23/32
Verifying : libselinux-python-2.5-12.el7.x86_64 24/32
Verifying : setools-libs-3.3.8-2.el7.x86_64 25/32
Verifying : policycoreutils-2.5-22.el7.x86_64 26/32
Verifying : libsepol-2.5-8.1.el7.x86_64 27/32
Verifying : policycoreutils-python-2.5-22.el7.x86_64 28/32
Verifying : selinux-policy-targeted-3.13.1-192.el7.noarch 29/32
Verifying : selinux-policy-3.13.1-192.el7.noarch 30/32
Verifying : libselinux-2.5-12.el7.x86_64 31/32
Verifying : libselinux-utils-2.5-12.el7.x86_64 32/32
Installed:
containerd.io.x86_64 0:1.6.31-3.1.el7 docker-ce.x86_64 3:26.1.1-1.el7 docker-ce-cli.x86_64 1:26.1.1-1.el7
Dependency Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 docker-buildx-plugin.x86_64 0:0.14.0-1.el7
docker-ce-rootless-extras.x86_64 0:26.1.1-1.el7 docker-compose-plugin.x86_64 0:2.27.0-1.el7
fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7
slirp4netns.x86_64 0:0.4.3-4.el7_8
Dependency Updated:
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
libsemanage-python.x86_64 0:2.5-14.el7 libsepol.x86_64 0:2.5-10.el7
policycoreutils.x86_64 0:2.5-34.el7 policycoreutils-python.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
setools-libs.x86_64 0:3.3.8-4.el7
Complete!
[root@localhost cps]#
查看docker的版本与状态、运行docker、跑hello world
[root@localhost cps]# docker --version
Docker version 26.1.1, build 4cf5afa
[root@localhost cps]# sudo systemctl start docker
[root@localhost cps]# sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2024-05-06 23:44:02 PDT; 25s ago
Docs: https://docs.docker.com
Main PID: 4436 (dockerd)
Tasks: 8
Memory: 84.8M
CGroup: /system.slice/docker.service
└─4436 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
May 06 23:44:01 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
May 06 23:44:01 localhost.localdomain dockerd[4436]: time="2024-05-06T23:44:01.588475471-07:00" level=info msg="Starting up"
May 06 23:44:01 localhost.localdomain dockerd[4436]: time="2024-05-06T23:44:01.659360350-07:00" level=info msg="Loading containers: start."
May 06 23:44:02 localhost.localdomain dockerd[4436]: time="2024-05-06T23:44:02.373728928-07:00" level=info msg="Firewalld: interface docker0 ...urning"
May 06 23:44:02 localhost.localdomain dockerd[4436]: time="2024-05-06T23:44:02.514195599-07:00" level=info msg="Loading containers: done."
May 06 23:44:02 localhost.localdomain dockerd[4436]: time="2024-05-06T23:44:02.569508838-07:00" level=info msg="Docker daemon" commit=ac2de55...=26.1.1
May 06 23:44:02 localhost.localdomain dockerd[4436]: time="2024-05-06T23:44:02.574600719-07:00" level=info msg="Daemon has completed initialization"
May 06 23:44:02 localhost.localdomain dockerd[4436]: time="2024-05-06T23:44:02.648808268-07:00" level=info msg="API listen on /run/docker.sock"
May 06 23:44:02 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost cps]# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:a26bff933ddc26d5cdf7faa98b4ae1e3ec20c4985e6f87ac0973052224d24302
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
[root@localhost cps]#
实验截图====================================
- kill 2755
搜索、拉取、查看docker镜像
[root@localhost cps]# docker search centos
NAME DESCRIPTION STARS OFFICIAL
centos DEPRECATED; The official build of CentOS. 7721 [OK]
kasmweb/centos-7-desktop CentOS 7 desktop for Kasm Workspaces 44
bitnami/centos-base-buildpack Centos base compilation image 0
dokken/centos-7 CentOS 7 image for kitchen-dokken 10
spack/centos7 CentOS 7 with Spack preinstalled 2
dokken/centos-8 CentOS 8 image for use with Test Kitchen's k… 6
dokken/centos-stream-8 CentOS Stream 8 image for use with Test Kitc… 5
dokken/centos-6 EOL: CentOS 6 image for kitchen-dokken 0
dokken/centos-stream-9 CentOS Stream 9 image for use with Test Kitc… 10
atlas/centos7-atlasos ATLAS CentOS 7 Software Development OS 3
spack/centos6 CentOS 6 with Spack preinstalled 1
eclipse/centos_jdk8 CentOS, JDK8, Maven 3, git, curl, nmap, mc, … 5
ustclug/centos Official CentOS Image with USTC Mirror 0
corpusops/centos-bare https://github.com/corpusops/docker-images/ 0
corpusops/centos centos corpusops baseimage 0
eclipse/centos_go Centos + Go 0
spack/centos-stream 2
fnndsc/centos-python3 Source for a slim Centos-based Python3 image… 0
eclipse/centos_spring_boot Spring boot ready image based on CentOS 0
openmicroscopy/centos-systemd-ip centos/systemd with iproute, for testing mul… 0
eclipse/centos CentOS based minimal stack with only git and… 1
eclipse/centos_nodejs CentOS based nodejs4 stack 0
eclipse/centos_vertx CentOS + vertx 0
eclipse/centos_wildfly_swarm CentOS, WildFly, Swarm 0
dockette/centos My Custom CentOS Dockerfiles 1
[root@localhost cps]# docker pull centos:7
7: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest: sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4
Status: Downloaded newer image for centos:7
docker.io/library/centos:7
[root@localhost cps]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest d2c94e258dcb 12 months ago 13.3kB
centos 7 eeb6ee3f44bd 2 years ago 204MB
[root@localhost cps]#
补充: 用户添加到docker组
默认情况下,普通用户不能使用Docker。
如果是管理员,可以使用sudo docker…来运行Docker指令。
如果不想要sudo,可以将一个用户添加到docker组,docker组中的用户无需sudo即可使用Docker指令。
将用户添加到Docker组:sudo usermod -aG docker 用户名
(执行这条指令,需要有root权限或者sudo权限,需要使用管理员或者root用户来执行)然后,newgrp docker
更新组权限
[root@localhost cps]# usermod -aG docker centos7-cps
[root@localhost cps]# newgrp docker
[root@localhost cps]# id centos7-cps
uid=1000(centos7-cps) gid=1000(centos7-cps) groups=1000(centos7-cps),10(wheel),982(docker)
[root@localhost cps]# su cetos7-cps
su: user cetos7-cps does not exist
[root@localhost cps]# su centos7-cps
[centos7-cps@localhost cps]$ whoami
centos7-cps
[centos7-cps@localhost cps]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
768ecbfafa57 hello-world "/hello" 25 hours ago Exited (0) 25 hours ago fervent_easley
[centos7-cps@localhost cps]$
容器创建并进入
基于centos7镜像,创建一个容器命名为test,并进入。
[root@localhost cps]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
768ecbfafa57 hello-world "/hello" 25 hours ago Exited (0) 25 hours ago fervent_easley
[root@localhost cps]# docker run -i -t --name test centos:7 /bin/bash
[root@3b9ecd977603 /]# whoami
root
[root@3b9ecd977603 /]# uname -a
Linux 3b9ecd977603 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@3b9ecd977603 /]# docker -v
bash: docker: command not found
[root@3b9ecd977603 /]#
新开一个终端进行对比,容器内安装没有docker,所以容器内docker -v不显示版本;
新开的终端查看容器状态,docker ps -a
可以看到多了一个容器,名叫test,基于centso7镜像创建,状态为Up启动。
[root@3b9ecd977603 /]# exit
exit
[root@localhost cps]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b9ecd977603 centos:7 "/bin/bash" 26 minutes ago Exited (127) 5 seconds ago test
768ecbfafa57 hello-world "/hello" 25 hours ago Exited (0) 25 hours ago fervent_easley
[root@localhost cps]#
使用Dockerfile 构建自定义镜像
1) 使用 docker commit,将本地容器提交,打包成镜像。这种方式生成的镜像体积较
大,且不可更改,软件更新不方便;
2) 采用 Dockerfile 构建容器。Dockerfile 是能被 docker 引擎解释的文本文件,用户通
过 Dockerfile 可以方便地自定义镜像。其体积也更小,利于传输。
[root@localhost cps]# mkdir http_test
[root@localhost cps]# cd http_test/
[root@localhost http_test]# cp /etc/yum.repos.d/CentOS-Base.repo .
[root@localhost http_test]# ls
CentOS-Base.repo
[root@localhost http_test]# vi Dockerfile
[root@localhost http_test]# cat Dockerfile
FROM centos:7
RUN rm -fv /etc/yum.repos.d/*
ADD CentOS-Base.repo /etc/yum.repos.d/
RUN yum install -y httpd
EXPOSE 80
[root@localhost http_test]# docker build -t httpd:v1.0 .
[+] Building 65.4s (9/9) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 216B 0.1s
=> [internal] load metadata for docker.io/library/centos:7 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [1/4] FROM docker.io/library/centos:7 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 1.77kB 0.0s
=> [2/4] RUN rm -fv /etc/yum.repos.d/* 1.0s
=> [3/4] ADD CentOS-Base.repo /etc/yum.repos.d/ 0.2s
=> [4/4] RUN yum install -y httpd 60.2s
=> exporting to image 3.3s
=> => exporting layers 3.2s
=> => writing image sha256:544daea3c3af47827361db50dbe04a1c68510e3183c9e7301009673570ba68d3 0.0s
=> => naming to docker.io/library/httpd:v1.0 0.0s
[root@localhost http_test]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd v1.0 544daea3c3af 35 seconds ago 487MB
hello-world latest d2c94e258dcb 12 months ago 13.3kB
centos 7 eeb6ee3f44bd 2 years ago 204MB
[root@localhost http_test]#
建立私有注册服务器
Docker 开源了 Docker Registry 代码,可以自己构建私有注册服务器。
① 查看宿主机ip
[root@localhost http_test]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:04:38:21 brd ff:ff:ff:ff:ff:ff
inet 192.168.196.52/24 brd 192.168.196.255 scope global noprefixroute dynamic ens33
valid_lft 1793sec preferred_lft 1793sec
inet6 fe80::466a:550e:e194:cd87/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:35:a8:24 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:35:a8:24 brd ff:ff:ff:ff:ff:ff
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:d1:e8:a8:40 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:d1ff:fee8:a840/64 scope link
valid_lft forever preferred_lft forever
② 下载注册服务器镜像
[root@localhost http_test]# docker search registry
NAME DESCRIPTION STARS OFFICIAL
registry Distribution implementation for storing and … 3991 [OK]
okteto/registry 0
okteto/registry-configurator 0
hephy/registry-proxy 0
okteto/registry-auth 0
hephy/registry Docker image registry for the Hephy - Fork o… 0
drud/registry 0
opensuse/registry Docker registry based on openSUSE. 1
hephy/registry-token-refresher 0
runcitadel/registry-photon 0
reseaucerta/registry 0
google/docker-registry Docker Registry w/ Google Cloud Storage driv… 55
docker/dtr Docker Trusted Registry 15
bitnami/harbor-registryctl Bitnami container image for Harbor Registryc… 2
bitnami/harbor-registry Bitnami container image for Harbor Registry 27
snyk/container-registry-agent Container registry agent allows securely con… 2
bitnami/schema-registry Bitnami container image for Schema Registry 0
docker/migrator Tool to migrate Docker images from a v1 regi… 8
apache/nifi-registry Unofficial convenience binaries for Apache N… 42
docker/trusted-registry-index Search Index for Docker Trusted Registry 0
verdaccio/verdaccio Verdaccio Official Docker Image: A lightweig… 192
joxit/docker-registry-ui Docker registry v2 web User Interface 138
corpusops/registry 0
opensuse/portus Authorization service and frontend for Docke… 96
jhipster/jhipster-registry JHipster Registry, based on Netflix Eureka a… 61
[root@localhost http_test]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
619be1103602: Pull complete
862815ae87dc: Pull complete
74e12953df95: Pull complete
6f0ce73649a0: Pull complete
ef4f267ce8ed: Pull complete
Digest: sha256:4fac7a8257b1d7a86599043fcc181dfbdf9c8f57e337db763ac94b0e67c6cfb5
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest
[root@localhost http_test]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd v1.0 544daea3c3af About an hour ago 487MB
registry latest d6b2c32a0f14 7 months ago 25.4MB
hello-world latest d2c94e258dcb 12 months ago 13.3kB
centos 7 eeb6ee3f44bd 2 years ago 204MB
③ 创建容器
[root@localhost http_test]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b9ecd977603 centos:7 "/bin/bash" 2 hours ago Exited (127) 2 hours ago test
768ecbfafa57 hello-world "/hello" 27 hours ago Exited (0) 27 hours ago fervent_easley
[root@localhost http_test]# docker run -d -p 5000:5000 --restart=always --name registry registry:latest
48adb0a36ded9cb6e7dfad01ddedf53361bb8d38d658c663916c9ec4b8da9e8f
[root@localhost http_test]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
48adb0a36ded registry:latest "/entrypoint.sh /etc…" About a minute ago Up About a minute 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp registry
3b9ecd977603 centos:7 "/bin/bash" 2 hours ago Exited (127) 2 hours ago test
768ecbfafa57 hello-world "/hello" 27 hours ago Exited (0) 27 hours ago fervent_easley
④ 给镜像打 tag
[root@localhost http_test]# docker tag d6b2c32a0f14 192.168.196.52:5000/registry:latest
⑤ 编辑配置文件,增加 insecure-registries 配置
[root@localhost http_test]# vi /etc/docker/daemon.json
[root@localhost http_test]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn"],
"insecure-registries": ["192.168.196.52:5000"]
}
[root@localhost http_test]# systemctl restart docker
⑥ 上传 registry 镜像
[root@localhost http_test]# docker push 192.168.100.31:5000/registry:latest
The push refers to repository [192.168.100.31:5000/registry]
An image does not exist locally with the tag: 192.168.100.31:5000/registry
[root@localhost http_test]# docker push 192.168.196.52:5000/registry:latest
The push refers to repository [192.168.196.52:5000/registry]
e8d8a60f42b5: Pushed
8135430299ba: Pushed
b2533b493853: Pushed
7908a7c94e63: Pushed
aedc3bda2944: Pushed
latest: digest: sha256:a9ea4b79e84f7c4a771c4a5b1a93d4542b1d1e2a1c575ad504e54ba53d220045 size: 1363
⑦ 访问测试
[root@localhost http_test]# curl http://192.168.196.52:5000/v2/registry/tags/list
{"name":"registry","tags":["latest"]}
[root@localhost http_test]#