Docker Community Forums

Share and learn in the Docker community.

Docker Container does not restart when using --net=host

I have a little ASP.NET Core application which runs fine within a Docker container on my Raspberry Pi 4. The command to start the container looks like this:

docker run --net=host -d --env-file /home/<<user>>/Docker/EReader/ereader.env --name ereader --restart always mu88/ereader:latest

As you can see, the container should restart on a system reboot (--restart always) and uses the daemon’s network (--net=host).

However, the container restart fails when rebooting the system. When running docker ps -a, the status of the container is Restarting (132) after the reboot.

I’ve tested some variations using the same image:

combination of… result after reboot
--net=host and --env-file container stuck in Restarting (132)
--net=host and several -e arguments container stuck in Restarting (132)
without --net=host, but with --env-file works, but logic inside the container fails because of missing network
without --net=host, but with -e arguments works, but logic inside the container fails because of missing network

So it seems to be related to --net=host.

Is there any known bug? Or am I doing it the wrong way? Can I somehow analyze what’s going on and why the container stucks in Restarting (132)?