Redhat7.9上安装Docker
一、linux环境说明
Red Hat Enterprise Linux 7.9 下载后(见参考1),vmware安装虚拟机
[root@localhost /]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
[root@localhost /]# cat /proc/version
Linux version 3.10.0-1160.el7.x86_64 (mockbuild@x86-vm-26.build.eng.bos.redhat.com) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Aug 18 14:50:17 EDT 2020
二、离线安装docker
step1:Uninstall old versions 卸载老版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
step2:离线安装docker相关组件
如果在线安装latest版本命令为:yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
前往网址https://download.docker.com/linux/centos/7/x86_64/stable/Packages/下载相应的rpm包,并将相关rpm包放置在指定文件夹下,如/opt/findig/PYTHON/docker-rpm/
cd /opt/findig/PYTHON/docker-rpm/
yum install docker-ce-rootless-extras-23.0.3-1.el7.x86_64.rpm docker-ce-23.0.3-1.el7.x86_64.rpm docker-ce-cli-23.0.3-1.el7.x86_64.rpm containerd.io-1.6.9-3.1.el7.x86_64.rpm docker-buildx-plugin-0.10.4-1.el7.x86_64.rpm docker-compose-plugin-2.6.0-3.el7.x86_64.rpm
#docker-ce-rootless-extras-23.0.3-1.el7.x86_64.rpm 是由于安装报错Error: Package: 3:docker-ce-23.0.3-1.el7.x86_64 (/docker-ce-23.0.3-1.el7.x86_64),Requires: docker-ce-rootless-extras
#安装时显示需要依赖其他的yum包,但是内网是非在线环境,不定能yum这些包,因此这个问题后续需要继续留意。on todo list
yum install docker-ce-rootless-extras-23.0.3-1.el7.x86_64.rpm docker-ce-23.0.3-1.el7.x86_64.rpm docker-ce-cli-23.0.3-1.el7.x86_64.rpm containerd.io-1.6.9-3.1.el7.x86_64.rpm docker-buildx-plugin-0.10.4-1.el7.x86_64.rpm docker-compose-plugin-2.6.0-3.el7.x86_64.rpm
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Repository base is listed more than once in the configuration
Examining docker-ce-rootless-extras-23.0.3-1.el7.x86_64.rpm: docker-ce-rootless-extras-23.0.3-1.el7.x86_64
Marking docker-ce-rootless-extras-23.0.3-1.el7.x86_64.rpm to be installed
Examining docker-ce-23.0.3-1.el7.x86_64.rpm: 3:docker-ce-23.0.3-1.el7.x86_64
Marking docker-ce-23.0.3-1.el7.x86_64.rpm to be installed
Examining docker-ce-cli-23.0.3-1.el7.x86_64.rpm: 1:docker-ce-cli-23.0.3-1.el7.x86_64
Marking docker-ce-cli-23.0.3-1.el7.x86_64.rpm to be installed
Examining containerd.io-1.6.9-3.1.el7.x86_64.rpm: containerd.io-1.6.9-3.1.el7.x86_64
Marking containerd.io-1.6.9-3.1.el7.x86_64.rpm to be installed
Examining docker-buildx-plugin-0.10.4-1.el7.x86_64.rpm: docker-buildx-plugin-0.10.4-1.el7.x86_64
Marking docker-buildx-plugin-0.10.4-1.el7.x86_64.rpm to be installed
Examining docker-compose-plugin-2.6.0-3.el7.x86_64.rpm: docker-compose-plugin-2.6.0-3.el7.x86_64
Marking docker-compose-plugin-2.6.0-3.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.9-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.6.9-3.1.el7.x86_64
Loading mirror speeds from cached hostfile
* elrepo: mirrors.tuna.tsinghua.edu.cn
---> Package docker-buildx-plugin.x86_64 0:0.10.4-1.el7 will be installed
---> Package docker-ce.x86_64 3:23.0.3-1.el7 will be installed
---> Package docker-ce-cli.x86_64 1:23.0.3-1.el7 will be installed
---> Package docker-ce-rootless-extras.x86_64 0:23.0.3-1.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-23.0.3-1.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-23.0.3-1.el7.x86_64
---> Package docker-compose-plugin.x86_64 0:2.6.0-3.el7 will be installed
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
---> 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 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
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================
Package Arch Version Repository Size
====================================================================================================
Installing:
containerd.io x86_64 1.6.9-3.1.el7 /containerd.io-1.6.9-3.1.el7.x86_64 112 M
docker-buildx-plugin x86_64 0.10.4-1.el7 /docker-buildx-plugin-0.10.4-1.el7.x86_64 53 M
docker-ce x86_64 3:23.0.3-1.el7 /docker-ce-23.0.3-1.el7.x86_64 94 M
docker-ce-cli x86_64 1:23.0.3-1.el7 /docker-ce-cli-23.0.3-1.el7.x86_64 34 M
docker-ce-rootless-extras
x86_64 23.0.3-1.el7 /docker-ce-rootless-extras-23.0.3-1.el7.x86_64 19 M
docker-compose-plugin x86_64 2.6.0-3.el7 /docker-compose-plugin-2.6.0-3.el7.x86_64 25 M
Installing for dependencies:
container-selinux noarch 2:2.119.2-1.911c772.el7_8
extras 40 k
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
Transaction Summary
====================================================================================================
Install 6 Packages (+4 Dependent packages)
Total size: 338 M
Total download size: 218 k
Installed size: 339 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/3): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:02
(2/3): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(3/3): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:02
----------------------------------------------------------------------------------------------------
Total 79 kB/s | 218 kB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 1/10
Installing : containerd.io-1.6.9-3.1.el7.x86_64 2/10
Installing : docker-compose-plugin-2.6.0-3.el7.x86_64 3/10
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 4/10
Installing : docker-buildx-plugin-0.10.4-1.el7.x86_64 5/10
Installing : 1:docker-ce-cli-23.0.3-1.el7.x86_64 6/10
Installing : fuse3-libs-3.6.1-4.el7.x86_64 7/10
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 8/10
Installing : docker-ce-rootless-extras-23.0.3-1.el7.x86_64 9/10
Installing : 3:docker-ce-23.0.3-1.el7.x86_64 10/10
Verifying : containerd.io-1.6.9-3.1.el7.x86_64 1/10
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 2/10
Verifying : 1:docker-ce-cli-23.0.3-1.el7.x86_64 3/10
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 4/10
Verifying : docker-ce-rootless-extras-23.0.3-1.el7.x86_64 5/10
Verifying : docker-buildx-plugin-0.10.4-1.el7.x86_64 6/10
Verifying : 3:docker-ce-23.0.3-1.el7.x86_64 7/10
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 8/10
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 9/10
Verifying : docker-compose-plugin-2.6.0-3.el7.x86_64 10/10
Installed:
containerd.io.x86_64 0:1.6.9-3.1.el7 docker-buildx-plugin.x86_64 0:0.10.4-1.el7
docker-ce.x86_64 3:23.0.3-1.el7 docker-ce-cli.x86_64 1:23.0.3-1.el7
docker-ce-rootless-extras.x86_64 0:23.0.3-1.el7 docker-compose-plugin.x86_64 0:2.6.0-3.el7
Dependency Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 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
Complete!
step3:启动docker服务
systemctl start docker
step4:检查docker服务启动情况
docker run hello-world
# Unable to find image 'hello-world:latest' locally,可用下面的语句验证
docker ps
#CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
docker images
#REPOSITORY TAG IMAGE ID CREATED SIZE
systemctl status docker
whereis docker
# docker ps | docker images | systemctl status docker | whereis docker 有结果后表示安装正常
[root@localhost docker-rpm]# whereis docker
docker: /usr/bin/docker /etc/docker /usr/libexec/docker /usr/share/man/man1/docker.1.gz
[root@localhost docker-rpm]# 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 2023-04-10 04:25:46 PDT; 2min 34s ago
Docs: https://docs.docker.com
Main PID: 92125 (dockerd)
Tasks: 7
Memory: 31.5M
CGroup: /system.slice/docker.service
└─92125 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Apr 10 04:25:45 localhost.localdomain dockerd[92125]: time="2023-04-10T04:25:45.230522695-07:00.
Apr 10 04:25:46 localhost.localdomain dockerd[92125]: time="2023-04-10T04:25:46.321515837-07:00.
Apr 10 04:25:46 localhost.localdomain dockerd[92125]: time="2023-04-10T04:25:46.487530628-07:00.
Apr 10 04:25:46 localhost.localdomain dockerd[92125]: time="2023-04-10T04:25:46.563220401-07:00.
Apr 10 04:25:46 localhost.localdomain dockerd[92125]: time="2023-04-10T04:25:46.585376472-07:00.
Apr 10 04:25:46 localhost.localdomain dockerd[92125]: time="2023-04-10T04:25:46.585494949-07:00.
Apr 10 04:25:46 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Apr 10 04:25:46 localhost.localdomain dockerd[92125]: time="2023-04-10T04:25:46.600629950-07:00.
Apr 10 04:25:46 localhost.localdomain dockerd[92125]: time="2023-04-10T04:25:46.609774794-07:00.
Apr 10 04:27:21 localhost.localdomain dockerd[92125]: time="2023-04-10T04:27:21.355834152-07:00.
Hint: Some lines were ellipsized, use -l to show in full.
step5:用image验证
待补充
参考
1、https://cloud.tencent.com/developer/article/2080004 Red Hat Enterprise Linux 7.9 下载
2、https://blog.csdn.net/lyqhf153/article/details/79585976 在Redhat/CentOS上安装Docker文章来源:https://www.toymoban.com/news/detail-712631.html
3、https://docs.docker.com/engine/install/centos/ Install Docker Engine on CentOS :官网!文章来源地址https://www.toymoban.com/news/detail-712631.html
到了这里,关于Redhat7.9上安装Docker的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!