中标麒麟离线安装Docker

参照官方Install static binaries的过程

安装Docker

  1. 在https://download.docker.com/linux/static/stable/下载对应版本的docker程序文件
  2. 解压文件: tar xzvf /path/to/<FILE>.tar.gz
  3. 把解压出来的文件移动到/usr/bin: sudo cp docker/* /usr/bin/
  4. 把docker注册为服务,创建文件/usr/lib/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
  1. 设置镜像源,创建配置文件: /etc/docker/daemon.json
    此处使用163的源,可以换其他源
{
  "registry-mirrors": ["http://hub-mirror.c.163.com"]
}
  1. 按顺序执行以下命令:
命令 说明
chmod +x /usr/lib/systemd/system/docker.service 对docker.service授予执行权限
systemctl daemon-reload 重载服务配置
systemctl start docker 运行docker
systemctl status docker 运行docker
systemctl enable docker 使docker自动启动

使用其他用户执行docker命令

sudo groupadd docker          #添加docker用户组
sudo gpasswd -a $USER docker  #将登陆用户加入到docker用户组中
newgrp docker                 #更新用户组
posted @ 2022-04-05 16:29  白纸无字Zonciu  阅读(843)  评论(0编辑  收藏  举报
桂ICP备15001930号-4