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
相关推荐
Maple_land8 分钟前
Linux进程第八讲——进程状态全景解析(二):从阻塞到消亡的完整生命周期
linux·运维·服务器·c++·centos
爱吃生蚝的于勒12 分钟前
【Linux】零基础学会Linux之权限
linux·运维·服务器·数据结构·git·算法·github
Cyan_RA931 分钟前
Linux 远程Ubuntu服务器本地部署大模型 EmoLLM 中常见的问题及解决方案 万字详解
linux·运维·服务器·ubuntu·大模型·远程部署·emollm
minji...43 分钟前
Linux相关工具vim/gcc/g++/gdb/cgdb的使用详解
linux·运维·服务器·c++·git·自动化·vim
web安全工具库1 小时前
Linux 高手进阶:Vim 核心模式与分屏操作详解
linux·运维·服务器·前端·数据库
不会调制解调的猫1 小时前
笔记 | 内网服务器通过wifi穿透,设置流量走向
运维·服务器·笔记
计算机小手2 小时前
推荐一个 GitHub 开源项目信息卡片生成工具,支持Docker快速部署和API调用
经验分享·docker·github·开源软件
半桔2 小时前
【网络编程】网络通信基石:从局域网到跨网段通信原理探秘
linux·运维·网络协议·php
sailwon3 小时前
自己搭建远程桌面服务器——私有化部署RustDesk
运维·服务器·云计算·远程工作
Garc3 小时前
Zookeeper删除提供者服务中的指定IP节点
linux·运维·服务器