How can I expose more than 1 port with Docker?

nubela picture nubela · Dec 30, 2013 · Viewed 305.4k times · Source

So I have 3 ports that should be exposed to the machine's interface. Is it possible to do this with a Docker container?

Answer

Tania Ang picture Tania Ang · Dec 31, 2013

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>