Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network_mode host is hard to use on Mac/Windows #7

Open
bb opened this issue Sep 23, 2021 · 0 comments
Open

network_mode host is hard to use on Mac/Windows #7

bb opened this issue Sep 23, 2021 · 0 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Comments

@bb
Copy link

bb commented Sep 23, 2021

Hi Kadir,

you chose to switch from port mapping to network_mode: host in docker-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. Then docker-compose exex meilipanel sh then ping 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 hostname host.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 or localhost 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).

@KadirFiratFTW KadirFiratFTW self-assigned this Sep 23, 2021
@KadirFiratFTW KadirFiratFTW added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants