From 8e35472d52c54ffb7a6b4088097d89885ab1a8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20S=C3=A1nchez=20Acosta?= Date: Fri, 17 Jun 2016 10:59:16 -0700 Subject: [PATCH] Update networking in a live container Provide documentation to map an additional port in a running container. --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ce2e1d..ef607b2 100644 --- a/README.md +++ b/README.md @@ -348,7 +348,11 @@ You can tell Docker that the container listens on the specified network ports at EXPOSE ``` -But note that EXPOSE does not expose the port itself, only `-p` will do that. +But note that EXPOSE does not expose the port itself, only `-p` will do that. To expose the container's port on your localhosts port: + +``` +iptables -t nat -A DOCKER -p tcp --dport -j DNAT --to-destination : +``` If you're running Docker in Virtualbox, you then need to forward the port there as well, using [forwarded_port](https://docs.vagrantup.com/v2/networking/forwarded_ports.html). It can be useful to define something in Vagrantfile to expose a range of ports so that you can dynamically map them: