docker离线配置安装

2022年6月11日10:28:43

一、CentOS 7

1、下载docker安装包:Index of linux/static/stable/x86_64/

2、将安装包随便放到系统某个目录下解压:tar -xvf docker-20.10.8.tgz

3、将解压后的docker目录中的所有内容拷贝到/usr/bin/目录下,放到此目录下相当于配置了环境变量即可以使用docker命令。(注:此处拷贝的内容不是整个docker目录而是docker目录下的所有文件

4、将docker注册为service:vim /etc/systemd/system/docker.service

[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=127.0.0.1
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

5、保存后给docker.service文件添加权限:chmod +x /etc/systemd/system/docker.service

6、重新加载配置文件(修改docker.service文件时都要重新加载下):systemctl daemon-reload

7、启动docker:systemctl start docker

8、设置开机启动:systemctl enable docker.service

9、查看docker状态:systemctl status docker

 10、查看docker版本:docker -v

  • 作者:走马川行雪
  • 原文链接:https://blog.csdn.net/weixin_43192102/article/details/120513134
    更新时间:2022年6月11日10:28:43 ,共 1571 字。