以下是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 -p
arguments:
docker run -p <host_port1>:<container_port1> -p <host_port2>:<container_port2>
或者你可以直接桥接网络,然后在dockerfile上面直接expose你所需要的端口,这样可以免去-p参数。
转载于:https://blog.51cto.com/yanconggod/1880348