Skip to content

Commit

Permalink
Update networking in a live container
Browse files Browse the repository at this point in the history
Provide documentation to map an additional port in a running container.
  • Loading branch information
Alejandro Sánchez Acosta authored Jun 17, 2016
1 parent 8eece99 commit 8e35472
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ You can tell Docker that the container listens on the specified network ports at
EXPOSE <CONTAINERPORT>
```

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 <LOCALHOSTPORT> -j DNAT --to-destination <CONTAINERIP>:<PORT>
```

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:

Expand Down

0 comments on commit 8e35472

Please sign in to comment.