Skip to content

Commit 1d9ca05

Browse files
committed
update docker: 离线安装步骤
1 parent 7ea7e89 commit 1d9ca05

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

book/杂技/Docker.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,78 @@ systemctl stop firewalld
154154
systemctl disable firewalld
155155
```
156156
157+
#### docker 离线安装
158+
159+
1. 本地下载 https://download.docker.com/linux/static/stable/x86_64/docker-24.0.2.tgz ,将安装包上传到服务器
160+
161+
2. 解压安装包:`tar -zxvf docker-24.0.2.tgz`
162+
163+
3. 拷贝解压出来的文件到 `/user/bin` 目录:`cp docker/* /usr/bin/`
164+
165+
4. 创建 docker.service 文件:
166+
167+
- 命令:
168+
169+
```shell
170+
cd /etc/systemd/system/
171+
touch docker.service
172+
vi docker.service # 文件内容拷贝下面的
173+
```
174+
175+
- 其中 docker.service 的内容:
176+
177+
```shell
178+
[Unit]
179+
Description=Docker Application Container Engine
180+
Documentation=https://docs.docker.com
181+
After=network-online.target firewalld.service
182+
Wants=network-online.target
183+
184+
[Service]
185+
Type=notify
186+
# the default is not to use systemd for cgroups because the delegate issues still
187+
# exists and systemd currently does not support the cgroup feature set required
188+
# for containers run by docker
189+
ExecStart=/usr/bin/dockerd
190+
ExecReload=/bin/kill -s HUP $MAINPID
191+
# Having non-zero Limit*s causes performance problems due to accounting overhead
192+
# in the kernel. We recommend using cgroups to do container-local accounting.
193+
LimitNOFILE=infinity
194+
LimitNPROC=infinity
195+
LimitCORE=infinity
196+
# Uncomment TasksMax if your systemd version supports it.
197+
# Only systemd 226 and above support this version.
198+
#TasksMax=infinity
199+
TimeoutStartSec=0
200+
# set delegate yes so that systemd does not reset the cgroups of docker containers
201+
Delegate=yes
202+
# kill only the docker process, not all processes in the cgroup
203+
KillMode=process
204+
# restart the docker process if it exits prematurely
205+
Restart=on-failure
206+
StartLimitBurst=3
207+
StartLimitInterval=60s
208+
209+
[Install]
210+
WantedBy=multi-user.target
211+
```
212+
213+
5. 给 docker.service 添加权限:
214+
215+
```shell
216+
chmod 777 /etc/systemd/system/docker.service # 给 docker.service 文件添加执行权限
217+
systemctl daemon-reload # 重新加载配置文件(每次有修改docker.service文件时都要重新加载下)
218+
```
219+
220+
6. 启动 docker:`systemctl start docker`
221+
222+
7. 设置 docker 开机自启:`systemctl enable docker.service`
223+
224+
#### docker 启动/关闭
225+
157226
通过命令启动 docker:
158227
159-
```sh
228+
```shell
160229
systemctl start docker # 启动 docer 服务
161230
162231
systemctl stop docker # 停止 docker 服务

0 commit comments

Comments
 (0)