Skip to content

Commit

Permalink
Merge pull request wsargent#102 from asancheza/patch-1
Browse files Browse the repository at this point in the history
Update networking in a live container
  • Loading branch information
wsargent authored Jun 17, 2016
2 parents 8eece99 + 8e35472 commit f55ecef
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 f55ecef

Please sign in to comment.