当前位置: 代码迷 >> 综合 >> Linux7.7离线安装Docker18.06.1
  详细解决方案

Linux7.7离线安装Docker18.06.1

热度:24   发布时间:2024-01-05 10:41:33.0

Linux7.7离线安装Docker18.06.1

一、基础环境

1、操作系统:CentOS 7.7

[root@localhost rabbit]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

2、Docker版本:18.06.1

下载网址:https://download.docker.com/linux/static/stable/x86_64/

3、参考官方文档地址:

https://docs.docker.com/engine/install/binaries/

二、Docker安装

1、下载并上传到服务器

2、解压

[root@localhost rabbit]# tar -zxvf 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@localhost rabbit]# cd docker/
[root@localhost docker]# ll
总用量 143620
-rwxr-xr-x. 1 user user 37589867 8月  22 2018 docker
-rwxr-xr-x. 1 user user 26393752 8月  22 2018 docker-containerd
-rwxr-xr-x. 1 user user 14725592 8月  22 2018 docker-containerd-ctr
-rwxr-xr-x. 1 user user  4173632 8月  22 2018 docker-containerd-shim
-rwxr-xr-x. 1 user user 53072264 8月  22 2018 dockerd
-rwxr-xr-x. 1 user user   764144 8月  22 2018 docker-init
-rwxr-xr-x. 1 user user  2837280 8月  22 2018 docker-proxy
-rwxr-xr-x. 1 user user  7495056 8月  22 2018 docker-runc

3、将解压出来的docker文件内容移动到 /usr/bin/ 目录下

[root@localhost rabbit]# cp docker/* /usr/bin

4、将docker注册为service

[root@localhost rabbit]# 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

5、启动

#添加文件权限
[root@localhost rabbit]# chmod +x /etc/systemd/system/docker.service
#重载unit配置文件
[root@localhost rabbit]# systemctl daemon-reload
#启动Docker
[root@localhost rabbit]# systemctl start docker 
#设置开机启动
[root@localhost rabbit]# systemctl enable docker.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /etc/systemd/system/docker.service.

6、验证

#查看Docker状态
[root@localhost rabbit]# systemctl status docker 
● docker.service - Docker Application Container EngineLoaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: disabled)Active: active (running) since 四 2021-05-06 16:07:09 CST; 25s agoDocs: https://docs.docker.comMain PID: 10971 (dockerd)CGroup: /system.slice/docker.service├─10971 /usr/bin/dockerd└─10985 docker-containerd --config /var/run/docker/containerd/containerd.toml5月 06 16:07:08 localhost.localdomain dockerd[10971]: time="2021-05-06T16:07:08.638626116+08:00" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc4201c...odule=grpc 5月 06 16:07:08 localhost.localdomain dockerd[10971]: time="2021-05-06T16:07:08.638823503+08:00" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc4201c...odule=grpc
5月 06 16:07:08 localhost.localdomain dockerd[10971]: time="2021-05-06T16:07:08.638841544+08:00" level=info msg="Loading containers: start."
5月 06 16:07:09 localhost.localdomain dockerd[10971]: time="2021-05-06T16:07:09.089848253+08:00" level=info msg="Default bridge (docker0) is assigned with an IP addre...P address"
5月 06 16:07:09 localhost.localdomain dockerd[10971]: time="2021-05-06T16:07:09.208372050+08:00" level=info msg="Loading containers: done."
5月 06 16:07:09 localhost.localdomain dockerd[10971]: time="2021-05-06T16:07:09.246718784+08:00" level=info msg="Docker daemon" commit=e68fc7a graphdriver(s)=overlay2...18.06.1-ce
5月 06 16:07:09 localhost.localdomain dockerd[10971]: time="2021-05-06T16:07:09.247958855+08:00" level=info msg="Daemon has completed initialization"
5月 06 16:07:09 localhost.localdomain dockerd[10971]: time="2021-05-06T16:07:09.265164335+08:00" level=warning msg="Could not register builder git source: failed to f... in $PATH"
5月 06 16:07:09 localhost.localdomain dockerd[10971]: time="2021-05-06T16:07:09.275162002+08:00" level=info msg="API listen on /var/run/docker.sock"
5月 06 16:07:09 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.#查看Docker版本
[root@localhost rabbit]# docker -v 
Docker version 18.06.1-ce, build e68fc7a

参考:

https://www.cnblogs.com/luoSteel/p/10038954.html