This option makes it so that the container uses the networking stack of the host. I went with this approach instead of having MongoDB and RabbitMQ listen on the docker bridge because it gives more flexibility.Ī simple but relatively insecure way would be to use the -net=host option to docker run. I had to do this trick to get any internet connection withing the container: My firewall is blocking network connections from the docker container to outsideĮDIT: Eventually I went with creating a custom bridge using pipework and having the services listen on the bridge IP's.
Nmap done: 1 IP address (1 host up) scanned in 13.31 seconds
#Linux port forward utility install#
Nmap scan report for localhost (127.0.0.1)Ħ311/tcp open ~ % docker run -i -t base apt-get install nmap 172.16.42.1 -p 6311 # IP found via docker inspect -> gateway internet) from within the Docker container but I'd like to not expose the RabbitMQ and MongoDB ports from the host to the outside world.ĮDIT: some clarification: Starting Nmap 5.21 ( ) at 22:39 CEST I know I can forward a port from the container to the host (via the -p option) and have a connection to the outside world (i.e. Is it possible to have a Docker container access ports opened by the host? Concretely I have MongoDB and RabbitMQ running on the host and I'd like to run a process in a Docker container to listen to the queue and (optionally) write to the database.