redHat9 安装 docker、docker-compose、iptables 过程记录

复制代码
  1. 确认 Linux 版本:
bash 复制代码
cat /etc/redhat-release
复制代码
我这里显示:Red Hat Enterprise Linux release 9.2 (Plow)
  1. 准备 docker 离线安装包:
bash 复制代码
我这里是从阿里云开源镜像站 https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/ 提前下载好的 docker-24.0.7.tgz
  1. 解压离线安装包:
bash 复制代码
tar -zxvf docker-24.0.7.tgz
  1. 将解压出来的 docker 文件夹下的全部内容复制到 /usr/bin 下:
bash 复制代码
cp docker/* /usr/bin/
  1. 将 docker 注册为 service 服务:

5.1. 新建 docker.service 文件:

bash 复制代码
     touch  /etc/systemd/system/docker.service

5.2. vim 编辑 /etc/systemd/system/docker.service 文件,输入如下内容:

bash 复制代码
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
  1. 为文件 docker.service 添加可执行权限:
bash 复制代码
chmod a+x /etc/systemd/system/docker.service
  1. 重新加载 systemd 配置:
bash 复制代码
systemctl daemon-reload
  1. 启动 docker 服务:
bash 复制代码
systemctl start docker
复制代码
     ps:这一步可能会失败,报如下错:
bash 复制代码
    Job for docker.service failed because the control process exited with error code.
    See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.
复制代码
  执行 systemctl status docker.service 和 journalctl -xeu docker.service 也看不出什么有用的根本信息,都是诸如 xxx start failed 之类的报错信息,百度也都是建议重装什么的,也没分析出实质性问题,其实手动执行文件 /etc/systemd/system/docker.service 中的 ExecStart 指向的命令,即 /usr/bin/dockerd,会看到根本性的错误,我这里就是说 "iptables not found",我查了资料说是红帽9不建议用 iptables 作为防火墙软件( 使用的是 firewall ),我咨询了公司的运维大牛,他说可以安装iptables,就当做普通的软件安装就行,安装完 iptables,docker 可以启动成功了( 安装步骤参见 redHat9 安装 iptables 过程记录  )
  1. 将 docker 服务设置为开机启动:
bash 复制代码
 systemctl enable docker
  1. 安装 docker-compose:https://objects.githubusercontent.com/docker-compose-Linux-x86_64

10.1. 下载 docker-compose 离线安装包:

bash 复制代码
    下载地址 https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-linux-x86_64

10.2. 将而进行文件 docker-compose-Linux-x86_64 移动到 /usr/bin/ 下并重命名为 docker-compose:

bash 复制代码
    mv docker-compose-Linux-x86_64 /usr/bin/docker-compose

10.3. 为 docker-compose 文件添加可执行权限:

bash 复制代码
    chmod +x /usr/bin/docker-compose

10.4. 查看 docker-compose 的版本已确定是否安装成功:

bash 复制代码
    docker-compose -v
相关推荐
lllsure3 小时前
Linux 实用指令
linux·物联网
努力的小T3 小时前
使用 Docker 部署 Apache Spark 集群教程
linux·运维·服务器·docker·容器·spark·云计算
Nerd Nirvana4 小时前
OpenSSL crt & key (生成一套用于TLS双向认证的证书密钥)
linux·ssl·shell·认证·加密·tls·oepnssl
letisgo54 小时前
记录一次部署PC端网址全过程
linux·阿里云·服务器运维
猫猫的小茶馆5 小时前
【网络编程】UDP协议
linux·服务器·网络·网络协议·ubuntu·udp
尚墨11115 小时前
linux 安装启动zookeeper全过程及遇到的坑
linux·zookeeper
东风微鸣5 小时前
TTRSS 迁移实战
docker·云原生·kubernetes·可观察性
鱼嘻5 小时前
Linux自学day23-进程和线程
linux·服务器·c语言·进程和线程
AuGuSt_815 小时前
在windows下安装windows+Ubuntu16.04双系统(下)
linux·ubuntu·双系统
old_power5 小时前
Linux(Ubuntu24.04)源码编译安装OpenCV4.6.0
linux·opencv