博主头像
李鑫冬律师的Cyber空间

李鑫冬律师的网络笔记

记一次Docker 因网桥名冲突启动失败处理过程

周末在家里,把废旧的笔记本装上Vmware Workstation 开始折腾,虚拟机装了一个Debian12系统,改造成旁路由。装了Adguard Home、mosdns、上网工具和Docker,Docker中装了alist和Portainer,但装完之后准备搞frp重启时发现docker无法启动,于是我输入命令: systemctl start docker,发现提示以下报错信息:

Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.

我输入命令 systemctl status docker.service ,提示了以下报错信息:

x docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sat 2024-03-09 11:30:41 CST; 57s ago
TriggeredBy: x docker.socket
       Docs: https://docs.docker.com
    Process: 4174 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.soc>
   Main PID: 4174 (code=exited, status=1/FAILURE)
        CPU: 591ms

Mar 09 11:30:41 debian systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Mar 09 11:30:41 debian systemd[1]: Stopped docker.service - Docker Application Container Engine.
Mar 09 11:30:41 debian systemd[1]: docker.service: Start request repeated too quickly.
Mar 09 11:30:41 debian systemd[1]: docker.service: Failed with result 'exit-code'.
Mar 09 11:30:41 debian systemd[1]: Failed to start docker.service - Docker Application Container >

我继续输入 dockerd 命令启动docker,提供了详细的报错原因:

INFO[2024-03-09T11:44:47.470346012+08:00] Starting up
WARN[2024-03-09T11:44:47.470711849+08:00] Running experimental build
INFO[2024-03-09T11:44:47.544789784+08:00] [graphdriver] using prior storage driver: overlay2
INFO[2024-03-09T11:44:47.549116419+08:00] Loading containers: start.
INFO[2024-03-09T11:44:48.254540012+08:00] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address
INFO[2024-03-09T11:44:48.257842839+08:00] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
failed to start daemon: Error initializing network controller: error creating default "bridge" network: cannot create network 02769243eebdd8c56e5d18f6329ef788aa0b0f8bbbd2c6a5277071b706c8021e (docker0): conflicts with network a9689dd88f7d388157ba0520e451c02fd9015a6e30d2b654735d308c347529ee (docker0): networks have same bridge name

看起来是由于网桥名称相同,导致无法启动,于是在stackoverflow找到解决方案:
输入以下命令,删除网络即可

sudo rm -rf /var/lib/docker/network
sudo systemctl start docker

当然,也可以选择另一种方案:

ip link del docker0
rm -rf /var/docker/network/*
mkdir -p /var/docker/network/files
systemctl start docker
# delete all containers
docker ps -a | cut -d' ' -f 1 | xargs -n 1 echo docker rm  -f
# recreate all containers

相关链接:Error creating default "bridge" network: cannot create network (docker0): conflicts with network (docker0): networks have same bridge name

发表新评论