Docker | docker0 has IP (is accessable from external) only at first run

  docker, networking

When I start a simple docker container (e.g. Portainer) with

docker run -d --name portainer -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer

the container is accessable from the internet as expected.

When I stop (docker stop portainer) and start (docker start portainer) the container, the port 9000 is open again (verified with nmap), but the web interface of portainer loads forever.

# first run
networkctl

 IDX LINK            TYPE     OPERATIONAL SETUP      
   1 lo              loopback carrier     configured 
   2 enp35s0         ether    routable    configured 
   3 enp36s0         ether    no-carrier  configuring
   5 br-1815f2210327 bridge   no-carrier  configuring
   6 br-7f9b2f2637a1 bridge   no-carrier  configuring
   7 br-a9ae27884558 bridge   no-carrier  configuring
6552 br-39aac8ad8ef3 bridge   routable    configuring
6559 docker0         bridge   no-carrier  configuring

# next run
networkctl

 IDX LINK            TYPE     OPERATIONAL SETUP      
   1 lo              loopback carrier     configured 
   2 enp35s0         ether    routable    configured 
   3 enp36s0         ether    no-carrier  configuring
   5 br-1815f2210327 bridge   no-carrier  configuring
   6 br-7f9b2f2637a1 bridge   no-carrier  configuring
   7 br-a9ae27884558 bridge   no-carrier  configuring
6552 br-39aac8ad8ef3 bridge   no-carrier  configuring
6559 docker0         bridge   no-carrier  configuring

I already tried different workarounds that I found on the internet, like

nano /etc/docker/daemon.json

{ "debug": true, "bip": "172.20.0.1/16" }

and this config file in various configurations

nano /etc/systemd/network/docker0.network

#[Match]
#Name=docker0

#[Network]
#IPForward=yes

#[Network]
#Address=172.17.0.1/16

#[Link]
#Unmanaged=yes

(Currently everythings is commented out.)

When I restart the docker daemon with

systemctl restart docker

and then start the docker container

docker start portainer

it’s working fine again.

My system is a linux root server hosted by strato.de:

docker -v
Docker version 20.10.6, build 370c289

cat /etc/issue
Ubuntu 20.04.2 LTS

uname -r
5.4.0-73-generic

The problem occurs with all of my docker containers on that server.

I would be very grateful for any further tips.

Kind regards,
K1LLUM1N471

Source: Docker Questions

LEAVE A COMMENT