离线安装 docker
1、基础环境
操作系统:CentOS 7.8
docker 版本:18.06.1
2、docker 下载
2.1 官方地址
https://download.docker.com/linux/static/stable/x86_64/
2.2 百度云地址
链接:https://pan.baidu.com/s/1H-pDa9ZPh_fvi_t-x7KSGA 提取码:sg7a
2.3 官方参考文档
https://docs.docker.com/engine/install/binaries/
3、docker 安装
3.1 上传解压
[root@docker ~]# rz -E rz waiting to receive. [root@docker ~]# ls anaconda-ks.cfg docker-18.06.1-ce.tgz [root@docker ~]# tar -xvf docker-18.06.1-ce.tgz docker/ docker/docker-containerd docker/docker-proxy docker/docker docker/docker-runc docker/dockerd docker/docker-containerd-ctr docker/docker-containerd-shim docker/docker-init [root@docker ~]# ls docker/ docker docker-containerd-shim docker-proxy docker-containerd dockerd docker-runc docker-containerd-ctr docker-init
3.2 移动解压文件内容至 /usr/bin/ 目录下
[root@docker ~]# cp docker/* /usr/bin/ [root@docker ~]# ls /usr/bin/docker* /usr/bin/docker /usr/bin/docker-containerd-shim /usr/bin/docker-proxy /usr/bin/docker-containerd /usr/bin/dockerd /usr/bin/docker-runc /usr/bin/docker-containerd-ctr /usr/bin/docker-init
3.3 将 docker 注册为 service
[root@docker ~]# 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 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
3.4 启动 docker
[root@docker ~]# chmod +x /etc/systemd/system/docker.service #添加文件权限 [root@docker ~]# systemctl daemon-reload #重载unit配置文件 [root@docker ~]# systemctl start docker /#启动Docker [root@docker ~]# systemctl enable docker.service #设置开机自启 Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /etc/systemd/system/docker.service.
3.5 验证
[root@docker ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since 六 2020-07-25 17:23:24 CST; 28s ago Docs: https://docs.docker.com Main PID: 1707 (dockerd) CGroup: /system.slice/docker.service ├─1707 /usr/bin/dockerd └─1723 docker-containerd --config /var/run/docker/containerd/containerd.toml 7月 25 17:23:23 docker dockerd[1707]: time="2020-07-25T17:23:23.394502816+08:00" level=i...rpc 7月 25 17:23:23 docker dockerd[1707]: time="2020-07-25T17:23:23.394716555+08:00" level=i...rpc 7月 25 17:23:23 docker dockerd[1707]: time="2020-07-25T17:23:23.395095630+08:00" level=i...rpc 7月 25 17:23:23 docker dockerd[1707]: time="2020-07-25T17:23:23.395142000+08:00" level=i...t." 7月 25 17:23:24 docker dockerd[1707]: time="2020-07-25T17:23:24.082088050+08:00" level=i...ss" 7月 25 17:23:24 docker dockerd[1707]: time="2020-07-25T17:23:24.274261695+08:00" level=i...e." 7月 25 17:23:24 docker dockerd[1707]: time="2020-07-25T17:23:24.301752021+08:00" level=i...-ce 7月 25 17:23:24 docker dockerd[1707]: time="2020-07-25T17:23:24.302039079+08:00" level=i...on" 7月 25 17:23:24 docker systemd[1]: Started Docker Application Container Engine. 7月 25 17:23:24 docker dockerd[1707]: time="2020-07-25T17:23:24.406835353+08:00" level=i...ck" Hint: Some lines were ellipsized, use -l to show in full. [root@docker ~]# docker -v Docker version 18.06.1-ce, build e68fc7a