Linux下Docker离线安装二进制包
Docker常规安装方式是用yum等方式,这种方式需要能联网或者内网有自己的仓库,下面介绍Docker的二进制包安装方式
1、使用root用户新建docker用户
1 groupadd docker 2 useradd -d /home/docker -m -g docker docker 3 passwd docker 4 #将root用户加入docker组,这样docker组的用户都可以使用docker命令 5 usermod -aG docker root
2、访问https://download.docker.com/linux/static/stable/x86_64/ 选择二进制包(如选择docker-18.06.3-ce.tgz),下载后上传至服务器上并解压至docker-18.06.3-ce目录
3、新建docker.service文件
1 [Unit] 2 Description=Docker Application Container Engine 3 Documentation=https://docs.docker.com 4 After=network-online.target firewalld.service 5 Wants=network-online.target 6 [Service] 7 Type=notify 8 # the default is not to use systemd for cgroups because the delegate issues still 9 # exists and systemd currently does not support the cgroup feature set required 10 # for containers run by docker 11 ExecStart=/usr/bin/dockerd 12 ExecReload=/bin/kill -s HUP $MAINPID 13 # Having non-zero Limit*s causes performance problems due to accounting overhead 14 # in the kernel. We recommend using cgroups to do container-local accounting. 15 LimitNOFILE=infinity 16 LimitNPROC=infinity 17 LimitCORE=infinity 18 # Uncomment TasksMax if your systemd version supports it. 19 # Only systemd 226 and above support this version. 20 #TasksMax=infinity 21 TimeoutStartSec=0 22 # set delegate yes so that systemd does not reset the cgroups of docker containers 23 Delegate=yes 24 # kill only the docker process, not all processes in the cgroup 25 KillMode=process 26 # restart the docker process if it exits prematurely 27 Restart=on-failure 28 StartLimitBurst=3 29 StartLimitInterval=60s 30 [Install] 31 WantedBy=multi-user.target
3、root用户执行如下语句将docker执行文件加入Path
1 #添加可执行权限 2 chmod a+x docker-18.06.3-ce/* 3 cp docker-18.06.3-ce/* /usr/bin/ 4 #拷贝文件到系统目录,将docker注册为service: 5 cp docker-18.06.3-ce/docker.service /etc/systemd/system/ 6 #添加文件权限并启动docker 7 chmod +x /etc/systemd/system/docker.service 8 #重载unit配置文件 9 systemctl daemon-reload 10 #启动Docker 11 systemctl start docker 12 #设置开机自启 13 systemctl enable docker.service 14 #查看Docker状态 15 systemctl status docker 16 #查看Docker版本 17 docker –v
每天进步一点点