断网状态下,使用二进制文件安装docker。
有几种安装的方式,rpm离线安装没测试成功,缺了很多相关的rpm包,怎么都补不全就放弃了。
一、参考文章
官方文档 https://docs.docker.com/install/linux/docker-ce/binaries/
Github https://github.com/docker/machine/issues/652
https://blog.csdn.net/ywd1992/article/details/82897394
https://blog.csdn.net/hu_wen/article/details/82855719
https://www.cnblogs.com/yingsi/p/8324452.html
https://blog.csdn.net/u013058742/article/details/80075633
https://blog.csdn.net/GentleLin/article/details/90294324
二、下载和配置
docker版本:docker-17.12.0-ce.tgz
下载地址:https://download.docker.com/linux/static/stable/,进入x86_64目录,选择对应的版本下载。
1.上传到服务器目录下,解压文件。
tar -xvf docker-17.12.0-ce.tgz
2.将解压出来的docker文件内容移动到 /usr/bin/ 目录下,该命令使用sudo进行,否则可能会出现权限不足的问题。
sudo cp docker/* /usr/bin/
3.将docker注册为service服务,建议在外部写好该文件再上传到指定目录下,比较方便,或者使用vim命令新建该文件。
vim /etc/systemd/system/docker.service
4.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
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
5.添加文件权限并启动docker 。
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker#启动Docker
systemctl enable docker.service#设置开机自启
6.查询相关信息。
systemctl status docker#查看Docker状态
docker -v#查看Docker版本
三、常见问题
1.启动报错,使用命令查看错误信息。
使用以下命令查看错误信息,查看错误日志信息为:/usr/bin/dockerd Permission denied,没有权限。
systemctl status docker
或
journalctl -xe
可以使用xftp6工具或者ls -l查看docker文件的权限,变更权限为 -rwxr-xr-x,才正确可以启动。
也使用以下方式进行授权,第2步。
$ chmod +x ~/docker
$ sudo cp ~/docker/* /usr/bin/
文章来源: www.oschina.net,作者:华山猛男,版权归原作者所有,如需转载,请联系作者。
原文链接:https://my.oschina.net/discussjava/blog/3109842