文章目录
1 离线安装docker(需要root权限)
1.1 安装过程
参考:《官方安装介绍》 https://docs.docker.com/install/linux/docker-ce/binaries/#install-static-binaries
参考:《Centos7 安装docker-18.03.1-ce(离线安装)》 https://blog.csdn.net/corbin_zhang/article/details/81325114
直接上网址:
Install Docker CE from binaries (官方文档:通过二进制包安装 docker 社区版)
简单介绍下安装步骤:
- 通过 FileZilla 等文件传输工具将 docker-18.03.1-ce.tar 放到用户目录下,并移动到该目录执行下述命令解压二进制包
$ tar xzvf docker-18.03.1-ce.tar
- 将解压出来的 docker 文件所有内容移动到
/usr/bin/
目录下
$ sudo cp docker/* /usr/bin/
1.2 docker注册为service(需要root)
参考:《Linux下离线安装Docker》 https://www.cnblogs.com/luosteel/p/10038954.html
关闭se :sudo setenforce 0
并将以下文件放入 /etc/systemd/system/docker.service 中,就可使用service docker restart/stop 等操作来启停docker
vim /etc/systemd/system/docker.service
按i
进入书写模式,填入下列文字:
[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