当前位置: 首页 > 图灵资讯 > 技术篇> 树莓派 docker服务启动失败

树莓派 docker服务启动失败

来源:图灵教育
时间:2023-05-15 09:29:14

原因:2021年劳动节结束后,发现几家线上docker服务都挂了。htop发现Gitlab太贵,占用了大量CPU,导致docker服务崩溃。但是docker服务多次重启都起不来。相关错误报告和解决方案如下

相关报错

1. 查看docker服务状态

systemctl status docker

树莓派 docker服务启动失败_重启

2. 查看docker 所有容器

docker ps -a
Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?
解决方案

在/etc/docker/目录创建daemon.json,添加以下内容:

{ "registry-mirrors": ["https://registry.docker-cn.com"]}

加载新的 unit 配置文件

sudo systemctl reload-daemon

下列操作命令重启

sudo systemctl  start  docker

树莓派 docker服务启动失败_树莓派_02

如果没有,试着重启树莓派

sudo reboot
兜底方案

删除docker服务

sudo yum erase -y docker-client.x86_64sudo yum erase -y docker-common.x86_64sudo yum remove docker \docker-common \container-selinux \docker-selinux \docker-engine

安装

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
附加docker.service 配置文件
cat /lib/systemd/system/docker.service
[Unit]Description=Docker Application Container EngineDocumentation=https://docs.docker.comAfter=network-online.target firewalld.service containerd.serviceWants=network-online.targetRequires=docker.socket containerd.service[Service]Type=notify# the default is not to use systemd for cgroups because the delegate issues still# exists and systemd currently does not support the cgroup feature set required# for containers run by dockerExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sockExecStart=ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sockExecReload=/bin/kill -s HUP $MAINPIDTimeoutSec=0restartsec=2restartttartsec==always# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.# Both the old, and new location are accepted by systemd 229 and up, so using the old location# to make them work for either version of systemd.StartLimitBurst=3# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make# this option work for either version of systemd.StartLimitInterval=60s# Having non-zero Limit*s causes performance problems due to accounting overhead# in the kernel. We recommend using cgroups to do container-local accounting.LimitNOFILE=infinityLimitNPROC=infinityLimitCORE=infinity# Comment TasksMax if your systemd version does not support it.# Only systemd 226 and above support this option.TasksMax=infinity# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=processOOMScoreAdjust=-500[Install]WantedBy=multi-user.target

参考

Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?

Docker can't connect to docker daemon