network_mode host is hard to use on Mac/Windows #7
Labels
bug
Something isn't working
documentation
Improvements or additions to documentation
enhancement
New feature or request
Hi Kadir,
you chose to switch from port mapping to
network_mode: host
indocker-compose.yml
, probably because users were trying to add a server as "127.0.0.1" and assumed it would be their laptop/desktop machine, but it was referring to the container itself.Networking on Mac (and Windows): the docker network mode “host” is kinda useless here as docker is not running natively on macOS (nor on Windows) but creates a virtual machine running Linux which is then the Docker host. The ports mapped via the ports param/setting are forwarded to the Mac or to Windows via an additional port mapping. However, the host mode only exposes the container’s ports to the (hidden) Linux docker host running in a VM on Mac/Windows, not to Mac/WIndows itself.
The most convenient way (which I know) to work around it is the host
host.docker.internal
which resolves to the Mac/Windows) hosts virtual IP address.Workaround/Fix
What I currently do is: I go back to a docker-compose.yaml with ports instead of network_mode host, then
docker-compose up -d --build
. Thendocker-compose exex meilipanel sh
thenping host.docker.internal
which shows the IP address which I can then enter into the “Add server” dialog. This would be a little bit easier when I could just add the hostnamehost.docker.internal
or e.g.http://host.docker.internal:7700/
in the add-server dialog (see #6).Further improvement idea
As users might not be aware of the described issue above, you might want to add a note if you could detect you're running in a Container on a Mac/Windows host (which I don't know how without mounting external volumes etc).
Or you could transparently try connecting to host.docker.internal if the user enters
127.0.0.1
orlocalhost
Either always or if you know you're running inside a Docker container. You could detect e.g. by checking for the file.dockerenv
in the root directory of the container).The text was updated successfully, but these errors were encountered: