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
相关推荐
shandianchengzi8 小时前
【记录】Tailscale|部署 Tailscale 到 linux 主机或 Docker 上
linux·运维·docker·tailscale
John Song8 小时前
Linux机器怎么查看进程内存占用情况
linux·运维·chrome
肉肉心很软10 小时前
使用onlyoffice实现文件预览编辑 + Docker一键部署流程
运维·docker·容器
-大头.10 小时前
Docker实战:构建高性能MySQL主从复制集群(读写分离)
mysql·docker·容器
LuiChun10 小时前
Docker Compose 容器服务查询与文件查看操作指南(Windows Docker Desktop 版)【一】
linux·运维·windows·docker·容器
${王小剑}10 小时前
在离线ubuntu上布置深度学习环境
linux·运维·ubuntu
Java程序之猿11 小时前
Linux使用U盘安装centos及报错You might want to saue “/run/initramfs/rdsosreport.txt“ 处理
linux·运维·服务器
goodlook012311 小时前
安装最新版本docker-26.1.4
运维·docker·容器
❀͜͡傀儡师11 小时前
docker安装部署PostgreSQL带有pgvector扩展向量数据(高维数组)
docker·postgresql·容器·pgvector
CC.GG11 小时前
【Linux】进程概念(五)(虚拟地址空间----建立宏观认知)
java·linux·运维