-
Notifications
You must be signed in to change notification settings - Fork 53
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
Local domain names and routing for Docker on Mac does not work #126
Comments
TODO:
|
Let me know if you need help with this. |
From https://docs.docker.com/docker-for-mac/networking/
|
We're running a bunch of local Drupal development environments on Docker and wanted to keep the Docker workflow with WP. Our local Drupal setup is based on Wodby's Docker4Drupal (https://github.com/Wodby/docker4drupal) and therefore we already had a robust container routing solution built on Træfik (https://docs.traefik.io/). Routing requests to the correct container is quite easy using Træfik:
The
That third part is something that is specific to using Anyway, I got the thing working on macOS with a bit of tinkering. It's not overly complicated but it does need Træfik, dnsmasq and macOS network settings properly configured. Also, the data volume mounts can be set to use user guided caching on macOS which makes them a lot faster. We've had stellar performance gains on our Drupal environments with them and they basically just work. If you guys want some help with this we're happy to help! |
Some people seem to run Traefik on localhost:80 and use it to route traffic to other containers. These setups don't have any DNS, they just use example.docker.localhost or example.host.internal, which is provided by default by Docker as a catch-all address to point to localhost IP. |
Did some experiements with Traefik. Results:
|
I tested
|
On Linux (e.g. Ubuntu 18.04) a simple docker-composer command is enough to get a fully equivalent developer experience as with
vagrant up
. The Docker container uses a bridged network, becomes visible with its own IP address to the Linux host, and advertises its local domain names with Avahi/mDNS. For example the IP and port here Nginx of the container would be listening could be 192.168.208.2:80. Users can simply openhttps://wordpress.local
in their browser and start working.On Mac however, the
network: bridge
stanza in thedocker-compose.yml
is not honored and it does not get its own IP address. Instead, the running container is only visible by the random port numbers assigned by Docker on the Docker host IP, for example 127.0.0.1:32774. The problem is twofold: no DNS is advertised, and even if it was, there is no real IP with a website served at port 80.The available solutions seems to be running a proxy container at 127.0.0.1:80 (and :443) that then directs all traffic to the actual containers inside the Docker network. Often https://github.com/jwilder/nginx-proxy seems to be used, together with https://github.com/jwilder/docker-gen to populate the proxy config. In addition you need something injected to the local DNS, and some people seem to use https://github.com/andyshinn/dnsmasq to highjack one TLD to be served from a local DNS server (for example *.test).
Considering there are also other challenges with Docker on Mac (e.g. slow data volume mounts, for which people seem to use e.g. http://docker-sync.io/ to speed them up) it seems that using Docker on Mac does not make much sense, and running the regular Vagrant box with all to tried and tested automation around networks, DNS and data mounts that Vagrant already has is a much cleaner solution with no known major drawbacks.
This issue should be kept open until somebody figures out how to run true bridged container networks on Docker for Mac (or if upstream introduces such features).
The text was updated successfully, but these errors were encountered: