一、上传下列文件到服务器【/opt】目录
containerd.io-1.2.5-3.1.el7.x86_64.rpm
docker-ce-cli-18.09.9-3.el7.x86_64.rpm
docker-ce-18.09.9-3.el7.x86_64.rpm
二、直接安装因为缺少依赖包会报以下信息。可从中得知依赖包版本
[root@centos opt]# yum install docker-ce-18.09.9-3.el7.x86_64.rpm
Loaded plugins: fastestmirror
Examining docker-ce-18.09.9-3.el7.x86_64.rpm: 3:docker-ce-18.09.9-3.el7.x86_64
Marking docker-ce-18.09.9-3.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:18.09.9-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-18.09.9-3.el7.x86_64
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00
file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /mnt/cdrom/repodata/repomd.xml"
Trying other mirror.
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.107-3.el7 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.107-3.el7.noarch
---> Package docker-ce.x86_64 3:18.09.9-3.el7 will be installed
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.9-3.el7.x86_64
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
--> Running transaction check
---> Package docker-ce.x86_64 3:18.09.9-3.el7 will be installed
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.9-3.el7.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-33.el7 will be installed
--> Processing Dependency: policycoreutils = 2.5-33.el7 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> 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 docker-ce.x86_64 3:18.09.9-3.el7 will be installed
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.9-3.el7.x86_64
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package policycoreutils.x86_64 0:2.5-29.el7 will be updated
---> Package policycoreutils.x86_64 0:2.5-33.el7 will be an update
---> 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.8.4-4.el7 will be updated
--> Processing Dependency: audit-libs(x86-64) = 2.8.4-4.el7 for package: audit-2.8.4-4.el7.x86_64
---> Package audit-libs.x86_64 0:2.8.5-4.el7 will be an update
---> Package docker-ce.x86_64 3:18.09.9-3.el7 will be installed
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Running transaction check
---> Package audit.x86_64 0:2.8.4-4.el7 will be updated
---> Package audit.x86_64 0:2.8.5-4.el7 will be an update
---> Package docker-ce.x86_64 3:18.09.9-3.el7 will be installed
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Finished Dependency Resolution
Error: Package: 3:docker-ce-18.09.9-3.el7.x86_64 (/docker-ce-18.09.9-3.el7.x86_64)
Requires: containerd.io >= 1.2.2-3
Error: Package: 3:docker-ce-18.09.9-3.el7.x86_64 (/docker-ce-18.09.9-3.el7.x86_64)
Requires: docker-ce-cli
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
三、安装 containerd.io-1.2.5-3.1.el7.x86_64.rpm
[root@centos opt]# yum install containerd.io-1.2.5-3.1.el7.x86_64.rpm
Loaded plugins: fastestmirror
Examining containerd.io-1.2.5-3.1.el7.x86_64.rpm: containerd.io-1.2.5-3.1.el7.x86_64
Marking containerd.io-1.2.5-3.1.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.2.5-3.1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================================================
Installing:
containerd.io x86_64 1.2.5-3.1.el7 /containerd.io-1.2.5-3.1.el7.x86_64 89 M
Transaction Summary
============================================================================================================================================================================================================
Install 1 Package
Total size: 89 M
Installed size: 89 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : containerd.io-1.2.5-3.1.el7.x86_64 1/1
Verifying : containerd.io-1.2.5-3.1.el7.x86_64 1/1
Installed:
containerd.io.x86_64 0:1.2.5-3.1.el7
Complete!
四、安装 docker-ce-cli-18.09.9-3.el7.x86_64.rpm
[root@centos opt]# yum install docker-ce-cli-18.09.9-3.el7.x86_64.rpm
Loaded plugins: fastestmirror
Examining docker-ce-cli-18.09.9-3.el7.x86_64.rpm: 1:docker-ce-cli-18.09.9-3.el7.x86_64
Marking docker-ce-cli-18.09.9-3.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package docker-ce-cli.x86_64 1:18.09.9-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================================================
Installing:
docker-ce-cli x86_64 1:18.09.9-3.el7 /docker-ce-cli-18.09.9-3.el7.x86_64 72 M
Transaction Summary
============================================================================================================================================================================================================
Install 1 Package
Total size: 72 M
Installed size: 72 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:docker-ce-cli-18.09.9-3.el7.x86_64 1/1
Verifying : 1:docker-ce-cli-18.09.9-3.el7.x86_64 1/1
Installed:
docker-ce-cli.x86_64 1:18.09.9-3.el7
Complete!
五、安装 docker-ce-18.09.9-3.el7.x86_64.rpm
[root@centos opt]# yum install docker-ce-18.09.9-3.el7.x86_64.rpm
Loaded plugins: fastestmirror
Examining docker-ce-18.09.9-3.el7.x86_64.rpm: 3:docker-ce-18.09.9-3.el7.x86_64
Marking docker-ce-18.09.9-3.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:18.09.9-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-18.09.9-3.el7.x86_64
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.cn99.com
file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /mnt/cdrom/repodata/repomd.xml"
Trying other mirror.
--> Processing Dependency: libcgroup for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.107-3.el7 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.107-3.el7.noarch
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-33.el7 will be installed
--> Processing Dependency: policycoreutils = 2.5-33.el7 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> 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 libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package policycoreutils.x86_64 0:2.5-29.el7 will be updated
---> Package policycoreutils.x86_64 0:2.5-33.el7 will be an update
---> 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.8.4-4.el7 will be updated
--> Processing Dependency: audit-libs(x86-64) = 2.8.4-4.el7 for package: audit-2.8.4-4.el7.x86_64
---> Package audit-libs.x86_64 0:2.8.5-4.el7 will be an update
--> Running transaction check
---> Package audit.x86_64 0:2.8.4-4.el7 will be updated
---> Package audit.x86_64 0:2.8.5-4.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================================================
Installing:
docker-ce x86_64 3:18.09.9-3.el7 /docker-ce-18.09.9-3.el7.x86_64 90 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.107-3.el7 extras 39 k
libcgroup x86_64 0.41-21.el7 base 66 k
libsemanage-python x86_64 2.5-14.el7 base 113 k
policycoreutils-python x86_64 2.5-33.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
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
policycoreutils x86_64 2.5-33.el7 base 916 k
Transaction Summary
============================================================================================================================================================================================================
Install 1 Package (+8 Dependent packages)
Upgrade ( 3 Dependent packages)
Total size: 93 M
Total download size: 2.9 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/11): audit-libs-2.8.5-4.el7.x86_64.rpm | 102 kB 00:00:00
(2/11): audit-2.8.5-4.el7.x86_64.rpm | 256 kB 00:00:00
(3/11): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(4/11): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
(5/11): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(6/11): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(7/11): container-selinux-2.107-3.el7.noarch.rpm | 39 kB 00:00:00
(8/11): policycoreutils-python-2.5-33.el7.x86_64.rpm | 457 kB 00:00:00
(9/11): policycoreutils-2.5-33.el7.x86_64.rpm | 916 kB 00:00:00
(10/11): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(11/11): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 3.9 MB/s | 2.9 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : audit-libs-2.8.5-4.el7.x86_64 1/15
Updating : policycoreutils-2.5-33.el7.x86_64 2/15
Installing : libcgroup-0.41-21.el7.x86_64 3/15
Installing : audit-libs-python-2.8.5-4.el7.x86_64 4/15
Installing : setools-libs-3.3.8-4.el7.x86_64 5/15
Installing : checkpolicy-2.5-8.el7.x86_64 6/15
Installing : python-IPy-0.75-6.el7.noarch 7/15
Installing : libsemanage-python-2.5-14.el7.x86_64 8/15
Installing : policycoreutils-python-2.5-33.el7.x86_64 9/15
Installing : 2:container-selinux-2.107-3.el7.noarch 10/15
Installing : 3:docker-ce-18.09.9-3.el7.x86_64 11/15
Updating : audit-2.8.5-4.el7.x86_64 12/15
Cleanup : policycoreutils-2.5-29.el7.x86_64 13/15
Cleanup : audit-2.8.4-4.el7.x86_64 14/15
Cleanup : audit-libs-2.8.4-4.el7.x86_64 15/15
Verifying : audit-libs-2.8.5-4.el7.x86_64 1/15
Verifying : policycoreutils-python-2.5-33.el7.x86_64 2/15
Verifying : audit-2.8.5-4.el7.x86_64 3/15
Verifying : libsemanage-python-2.5-14.el7.x86_64 4/15
Verifying : 2:container-selinux-2.107-3.el7.noarch 5/15
Verifying : 3:docker-ce-18.09.9-3.el7.x86_64 6/15
Verifying : python-IPy-0.75-6.el7.noarch 7/15
Verifying : checkpolicy-2.5-8.el7.x86_64 8/15
Verifying : policycoreutils-2.5-33.el7.x86_64 9/15
Verifying : setools-libs-3.3.8-4.el7.x86_64 10/15
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 11/15
Verifying : libcgroup-0.41-21.el7.x86_64 12/15
Verifying : policycoreutils-2.5-29.el7.x86_64 13/15
Verifying : audit-libs-2.8.4-4.el7.x86_64 14/15
Verifying : audit-2.8.4-4.el7.x86_64 15/15
Installed:
docker-ce.x86_64 3:18.09.9-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.107-3.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7
policycoreutils-python.x86_64 0:2.5-33.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
Dependency Updated:
audit.x86_64 0:2.8.5-4.el7 audit-libs.x86_64 0:2.8.5-4.el7 policycoreutils.x86_64 0:2.5-33.el7
Complete!
六、启动 docker 服务
systemctl start docker
七、运行 docker 测试用例
[root@centos opt]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
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/
八、查看本地 docker 镜像
[root@centos opt]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest fce289e99eb9 14 months ago 1.84kB
来源:oschina
链接:https://my.oschina.net/wutenghui/blog/3209528