I ran into this need and after googling, it took me way too long to eventually find the answer in the docs. Could be for debugging, or small projects, or whatever reason. Sometimes you need to be able to connect to the host network from inside a Docker container. NOTE: If your problem is connecting TO containers FROM a macOS host, see this post: Last tested with version Docker version 18.09.3 on Ubuntu 16.04, Debian 9 (stretch), macOS Mojave (10.14.4).
Two simple, quick methods to access the host network from a Docker container (updated for Docker 18.03, Linux & macOS) 03 November 2017 by