离线、在线安装docker

在线安装

curl -sSL https://get.daocloud.io/docker | sh

离线安装

下载docker

  • 官网链接 docker下载地址

上传到linux服务器

安装docker

  • 解压 tar -xvf docker-19.03.5.tgz
  • 放到/usr/bin目录 mv docker/* /usr/bin/

设置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

PS: 需要注意–insecure-registry=127.0.0.1中,这个127.0.0.1为自己私服镜像库IP地址。

  • 添加执行权限 chmod +x docker.service
  • 加载文件 systemctl daemon-reload
  • 启动 systemctl start docker
  • 设置开机自启systemctl enable docker

你可能感兴趣的:(笔记,docker,linux)