Docker: Access Host Ports

Sometimes you may want to access ports on your host from within a container. This is easily done by looking a the destination of the network gateway

user@docker $ netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}'
user@docker $ #your address may differ

You can now use this address. For example if the host were running a web server, you could access it from within a container with

user@docker $ curl

If netstat is installed via net-tools ($ apt install net-tools).