Files
Kubernetes/Docker/Files/docker.service
offends 103ee74cab
All checks were successful
continuous-integration/drone Build is passing
修改Docker文档目录层级,更新Docker脚本,更新Docker文档
2025-11-06 23:06:28 +08:00

48 lines
2.0 KiB
Desktop File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Github仓库示例地址: https://github.com/moby/moby/blob/master/contrib/init/systemd/docker.service
# 文件位置: /usr/lib/systemd/system/docker.service
[Unit]
# 服务的描述信息
Description=Docker Application Container Engine
# 指向 Docker 官方文档,便于 systemd 工具读取帮助信息
Documentation=https://docs.docker.com
# 在网络完全上线、DNS 可用、docker.socket、firewalld、containerd 等服务就绪后再启动
After=network-online.target nss-lookup.target docker.socket firewalld.service containerd.service time-set.target
# 希望这些服务也在启动时被激活,但不是强制依赖
Wants=network-online.target containerd.service
# Docker 服务依赖 docker.socket否则无法启动
Requires=docker.socket
# 在设定时间窗口内允许最多 3 次启动失败
StartLimitBurst=3
# 启动失败计数的时间窗口为 60 秒
StartLimitIntervalSec=60
[Service]
# Docker 使用 systemd 的通知机制汇报启动是否完成
Type=notify
# Docker 守护进程的启动命令fd:// 表示让 systemd 管理 socket指定 containerd 套接字路径
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
# 重载配置时给主进程发送 HUP 信号
ExecReload=/bin/kill -s HUP $MAINPID
# 不限制启动超时时间,避免因系统繁忙造成 dockerd 启动失败
TimeoutStartSec=0
# 发生失败重启前等待 2 秒
RestartSec=2
# 无论因何原因退出都自动重启
dRestart=always
# 设为无限以避免内核资源统计带来的性能开销
LimitNPROC=infinity
LimitCORE=infinity
# 允许 Docker 创建任意数量的任务(需 systemd 226+
TasksMax=infinity
# 允许 docker 自己管理其 cgroups不受 systemd 重置影响
Delegate=yes
# 杀进程时只杀主进程,不影响容器子进程
KillMode=process
# 降低 Docker 在内存不足OOM时被内核优先杀掉的概率
OOMScoreAdjust=-500
[Install]
# 让服务在多用户运行级别自动启动
WantedBy=multi-user.target