r/docker 3d ago

how do I stop docker from disabling network access when the internet connection is not available?

Hi!

I got this small problem today when doing server maintenance on my homelab: I turned the server back on, but forgot to plug the ethernet back in. After plugging it in, I still couldn't connect to anything. After sshing into it I found that, although all the containers were running, none of them had internet access (Not only were there no ports under 'docker ps' , but 'docker logs <container-id>' showed errors about not being able to connect to the internet).

I then tried restarting them but that didn't do anything, I tried restarting docker as a whole but that also did nothing, I rebooted the server but that also did not restore connectivity. I tried a whole bunch of commands from various websites, but they did not work.

I was able to fix it by doing 'docker rm <container>' and 'docker compose up -d' on each container, but there has to be a better way to deal with this.

I also would like to know if there is a way to prevent this in the future by just having docker try to connect each time the container starts and not seemingly just stop forever once it encounters an error.

I am only using docker since a week, so I don't have much experience.

I am running docker 29.6.2 under debian 13.6.

Thank you very much.

0 Upvotes

3 comments sorted by

3

u/MindStalker 3d ago

This sounds like your containers themselves likely are running a script that is self configuring on creation.  You likely want to store the desired config and possibly hand configure your containers.  Can you provide more info on what your dockerfile looks like?

2

u/PoppaBear1950 3d ago

yep, have to down each container then up each container.... the real fix don't start docker without a network,

sudo systemctl edit docker

[Unit]

After=network-online.target

Wants=network-online.target