中標麒麟離線安裝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                 #更新用戶組


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM