mirror of
https://github.com/wsargent/docker-cheat-sheet.git
synced 2025-12-16 07:00:13 +01:00
Update networking in a live container
Provide documentation to map an additional port in a running container.
This commit is contained in:
parent
8eece99f9b
commit
8e35472d52
1 changed files with 5 additions and 1 deletions
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue