centOS7.3 离线安装docker

一、环境

 因某些环境,不能联外网,所以使用docker yum源方法行不通,于是打算离线安装

 环境:contos7.3(内核需为3.10+)

cat /etc/redhat-release
# CentOS Linux release 7.3.1611 (Core)

 下载:docker-18.06.3-ce.tar

 

二、安装步骤

 1)setup

cd /usr/local/resource/docker
tar -xzvf docker-18.06.3-ce.tar
mv  /usr/local/resource/docker/docker/*  /usr/bin/ # 将二进制文件移动到bin下

  2)systemd 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 -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
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

  授予执行权限:

chmod +x /etc/systemd/system/docker.service

  然后:

systemctl daemon-reload   # 重载systemd下 xxx.service文件
systemctl start docker       # 启动Docker
systemctl enable docker.service   # 设置开机自启

  测试是否成功:

systemctl status docker   # 查看Docker状态
docker -v # 查看Docker版本

  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章