Just a quick note (for my own memory more than anything)…
If you need to connect from a docker container to something running on your local host, it can be a bit of a pain on Linux. On windows & Mac, there’s a special DNS entry ‘host.docker.internal’ which always points to the host machine. However that isn’t available on Linux (here’s a bug open for this as of May 2018: https://github.com/docker/for-linux/issues/264)
That bug report also contains a pretty good solution for this problem, so to save you wading through, simply add the following line to your docker file:
RUN ip -4 route list match 0/0 | awk '{print $3 "host.docker.internal"}' >> /etc/hosts
That adds an entry to the container’s Host file, so host.docker.internal will resolve to your host just like it does on Mac / Windows.
until host.docker.internal is working for every platform you can use my container acting as a NAT gateway without any manually setup https://github.com/qoomon/docker-host
Nice solution, thanks !
missing a space before host.docker.internal
RUN ip -4 route list match 0/0 | awk ‘{print $3 ” host.docker.internal”}’ >> /etc/hosts