docker设置开机自启操作

一:开启自启服务文件配置

1:docker.socket

复制代码
sudo tee /usr/lib/systemd/system/docker.socket <<EOF
[Unit]
Description=Docker Socket for the API
[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
EOF

2:containerd.service

复制代码
sudo tee /usr/lib/systemd/system/containerd.service <<EOF
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target
[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999
[Install]
WantedBy=multi-user.target
EOF

3:docker.service

复制代码
sudo tee /usr/lib/systemd/system/docker.service <<EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket containerd.service
[Service]
Type=notify
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target
EOF

二:开机自启操作

复制代码
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
相关推荐
zfj3214 分钟前
Linux内核和发行版的的区别、职责
linux·运维·服务器·内核·linux发行版
qq_317620311 小时前
04:Docker-Compose完全指南
docker·容器编排·服务配置·依赖管理·多环境部署
我可以将你更新哟1 小时前
【docker】Dockerfile的编写
docker·容器
石像鬼₧魂石1 小时前
服务器安全配置自查清单(可打印版)
运维·服务器·安全
行初心1 小时前
uos基础 应用商店 查看应用程序的包名
运维
xiucai_cs2 小时前
实战:用 Claude Code 打造 AI 运维工程师
运维·人工智能
阿干tkl2 小时前
基于nginx服务文件上传及下载
运维·nginx
❀͜͡傀儡师2 小时前
docker部署orion-ops一站式智能运维管理平台
运维·docker·容器·orion-ops
闻道且行之2 小时前
Ubuntu 20.04 下 NVIDIA Tesla P40 驱动安装指南(核显桌面 + 计算卡分离方案)
linux·运维·ubuntu·nvidia·p40