以下是 stackoverflow 鬼老的回答:
To expose just one port, this is what you need to do:
- docker run - p < host_port > :<container_port >
To expose multiple ports, simply provide multiple
arguments:
- -p
- docker run - p < host_port1 > :<container_port1 > - p < host_port2 > :<container_port2 >
或者你可以直接桥接网络,然后在 dockerfile 上面直接 expose 你所需要的端口,这样可以免去 - p 参数。
来源: http://www.bubuko.com/infodetail-1863593.html