1.使用场景
在互联网的服务器上可以直接使用yum命令安装docker,但是如果在无网的服务器上,就只能使用离线安装包了
2. 安装
- docker离线包下载地址
- 准备好docker-service文件
注意:这里的配置文件里面的ExecStart将docker的存储路径设置成为了/work/docker
[Unit]Description=Docker Application Container EngineDocumentation=https://docs.docker.comAfter=network-online.target firewalld.serviceWants=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 dockerExecStart=/usr/bin/dockerd --graph /work/dockerExecReload=/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=infinityLimitNPROC=infinityLimitCORE=infinity# Uncomment TasksMax if your systemd version supports it.# Only systemd 226 and above support this version.#TasksMax=infinityTimeoutStartSec=0# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=process# restart the docker process if it exits prematurelyRestart=on-failureStartLimitBurst=3StartLimitInterval=60s[Install]WantedBy=multi-user.target
准备好daemon.json文件
{"log-driver":"json-file","log-opts": {"max-size":"500m", "max-file":"3"}}
使用tar命令解压,将docker/*所有文件复制或剪切到/usr/bin目录下
- 将我们准备好的docker.service复制到/etc/systemd/system目录下(docker.service记得赋执行权限 chmod +x docker.service)
- 将我们准备好的daemon.json文件复制或剪切到/etc/docker目录下去,没有此目录就自行创建
- 启动docker
- systemctl daemon-reload: 启动守护进程
- systemctl start docker: 启动docker
- systemctl enable docker.service: 开启开机自启动
- systemctl status docker :验证
