Change to host network

Hey everyone,

I am new to Docker and I’ve already created some containers. I want to use them as a Server but I am not able to change the network form bridge to host network. Does anybody know how to fix or solve this?


It is always good idea to share what you tried, so we can identify and point out what needs to be done differently.

Thank you for your reply. I have already done this:

I clicked on the container and I scrolled down to the section „connected metworks“. After that I clicked on the drop-down menu „Select a network“ and chose „host“. After that I got an error message.

I missed it’s about docker desktop.

As I am not using Docker Desktop for Linux, I can not say whether it works or not. But I doubt that it works, because the docker engine in Docker Desktop is isolated in a vm and sharing the host’s network with the vm is not possible.

Thank you for the reply.
Which category should I use for my question?

The category is fine. I just read the text and missed the category :blush:.

1 Like

As @meyay already noted, host network will not work. At least not the wayyou would expect, so it should not give you an error message, because sometimes you want to use the host network of the virtual machine. What was the error message? If you expect better advice, you should not keep the most important clue a secret :slight_smile:

I can’t test Docker Desktop for Linux now, but I couldn’t find the “Select network” option on my macOS and Windows.

it looks like this

As the error message says, you can’t connect to host network. It doesn’t say why, but the reason is that it is not a usual network that you could connect to. It is the lack of network isolation. You still have a bridge network. Even if you could choose host network from Portainer, you need to disconnect the bridge.

Our previous statement is stil true. It wouldn’t be the network of the actual host, but the network of the vitual machine so you would not be able to access your service. When you are using Docker Desktop, port forward or a reverse proxy (which has a forwarded port) is always necessary.

that’s why I have moved away from docker desktop back to docker engine(“bare metal docker”), because dealing with hardware is a pain with vm docker.
if you must use host network, I’d suggest you do the same