CentOS7.X离线安装docker
南江烂柯人 JAVA劝退师

第一种

下载docker的安装包

docker安装包
需要的依赖:

  1. docker-ce-cli
  2. containerd.io
  3. container-selinux

执行安装命令

先安装依赖再安装docker

1
2
3
4
5
6
rpm -ivh docker-ce-cli-24.0.4-1.el7.x86_64.rpm
rpm -ivh container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm
rpm -ivh containerd.io-1.6.9-3.1.el7.x86_64.rpm

rpm -ivh docker-ce-24.0.4-1.el7.x86_64.rpm

启动

1
2
3
4
5
6
7
# 启动
systemctl start docker
# 查看状态
systemctl status docker
# 开启docker开机自启动
systemctl enable docker.service

第二种

下载上传安装文件并解压安装

docker下载

将解压出来的docker文件复制到 /usr/bin/ 目录下

1
cp docker/* /usr/bin/

进入/etc/systemd/system/目录,并创建docker.service文件

1
2
cd /etc/systemd/system/
touch docker.service

打开docker.service文件,将以下内容复制 注意: –insecure-registry=192.168.200.128 此处改为你自己服务器ip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=192.168.200.128
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

给docker.service文件添加执行权限

1
chmod 777 /etc/systemd/system/docker.service 

重新加载配置文件(每次有修改docker.service文件时都要重新加载下)

1
systemctl daemon-reload 

启动配置

1
2
3
4
5
6
# 启动
systemctl start docker
# 设置开机启动
systemctl enable docker.service
# 查看状态
systemctl status docker
  • 本文标题:CentOS7.X离线安装docker
  • 本文作者:南江烂柯人
  • 创建时间:2022-11-22 10:10:00
  • 本文链接:https://www.mattjia.com/2022/11/22/installation/CentOS7.X离线安装docker/
  • 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
 评论