二进制安装docker

二进制部署docker

简介

​ 使用二进制部署docker有很多好处例如内网服务器中不可能让每台服务器下载这样会占用网络资源。所以使用二进制版本再结合自动化工具来部署或升级省时又省力

安装

1、下载二进制包

这里在阿里云镜像站点下载https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/

1
[root@node01 src]# wget https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/docker-19.03.13.tgz

2、解压下载好的二进制包

1
[root@node01 src]# tar xf docker-19.03.13.tgz

3、查看解压后的文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@node01 src]# ll
total 59308
drwxrwxr-x 2 1000 1000 138 May 15 08:29 docker
-rw-r--r-- 1 root root 60730088 Oct 21 09:47 docker-19.03.13.tgz
[root@node01 src]# ll docker
total 195504
-rwxr-xr-x 1 1000 1000 32751272 May 15 08:29 containerd
-rwxr-xr-x 1 1000 1000 6012928 May 15 08:29 containerd-shim
-rwxr-xr-x 1 1000 1000 18194536 May 15 08:29 ctr
-rwxr-xr-x 1 1000 1000 61113382 May 15 08:29 docker
-rwxr-xr-x 1 1000 1000 68874208 May 15 08:29 dockerd
-rwxr-xr-x 1 1000 1000 708616 May 15 08:29 docker-init
-rwxr-xr-x 1 1000 1000 2928514 May 15 08:29 docker-proxy
-rwxr-xr-x 1 1000 1000 9600696 May 15 08:29 runc

4、存放位置

拿到这么多可执行程序后,但是这些文件要搁哪比较合适呢,就要看你的docker.service文件里怎么定义了,这里还是安装官方的默认路径来放,存放到/usr/bin下

1
2
3
4
5
[root@node01 src]# cd docker/
[root@node01 docker]# cp -a ./* /usr/bin/
# 在输入docker命令时跟docker有关的命令
[root@node01 docker]# docker
docker dockerd docker-init docker-proxy

5、编写启动文件

需要这三个文件containerd.service、docker.service、docker.socket 可以从其他已经安装好的机器上拷贝过来

6、启动docker

一切都准备就绪之后可以启动docker了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
[root@node01 system]# systemctl daemon-reload
[root@node01 system]# systemctl start containerd
[root@node01 system]# systemctl start docker
A dependency job for docker.service failed. See 'journalctl -xe' for details.
[root@node01 system]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://docs.docker.com

Oct 21 10:17:55 node01.dklwj.com systemd[1]: Dependency failed for Docker Application Container Engine.
Oct 21 10:17:55 node01.dklwj.com systemd[1]: Job docker.service/start failed with result 'dependency'.
[root@node01 system]# tail -f /var/log/messages
Oct 21 10:17:50 node01 containerd: time="2020-10-21T10:17:50.627673143+08:00" level=info msg="Start event monitor"
Oct 21 10:17:50 node01 containerd: time="2020-10-21T10:17:50.627694928+08:00" level=info msg="Start snapshots syncer"
Oct 21 10:17:50 node01 containerd: time="2020-10-21T10:17:50.627709788+08:00" level=info msg="Start streaming server"
Oct 21 10:17:55 node01 systemd: Starting Docker Socket for the API.
Oct 21 10:17:55 node01 systemd: Failed to chown socket at step GROUP: No such process
Oct 21 10:17:55 node01 systemd: docker.socket control process exited, code=exited status=216
Oct 21 10:17:55 node01 systemd: Failed to listen on Docker Socket for the API.
Oct 21 10:17:55 node01 systemd: Dependency failed for Docker Application Container Engine.
Oct 21 10:17:55 node01 systemd: Job docker.service/start failed with result 'dependency'.
Oct 21 10:17:55 node01 systemd: Unit docker.socket entered failed state.
# 启动失败原因是没有docker组所以导致启动失败,在查看docker.socket文件时下面有项写着SocketGroup=docker所以必须要创建一个docker组
[root@node01 system]# cat /usr/lib/systemd/system/docker.socket
[Unit]
Description=Docker Socket for the API
PartOf=docker.service

[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker

[Install]
WantedBy=sockets.target
# 解决方法
[root@node01 system]# groupadd docker
[root@node01 system]# systemctl start docker
[root@node01 system]# docker info
Client:
Debug Mode: false

Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.13
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1062.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: node01.dklwj.com
ID: Y5XP:B5M3:BQQX:A7VZ:P3VJ:2K45:5KUQ:5SJ7:TIKB:XSTN:TVGG:EFQY
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

二进制安装docker
https://www.dklwj.com/2022/12/Binary-Install-Docker.html
作者
阿伟
发布于
2022年12月17日
许可协议