I need to map the ports on the host to the ports on the container. I can achieve this by running the \"docker run\"
command with the -p
option. How do
There's a difference between expose and publish.
Expose means to open the port on the container side, publish means to open it on the Docker host to the outside world.
For example, if your docker run command had -p 80:8080, it's exposing port 8080 on the container and publishing port 80 on the host.
You can only really expose ports in the Dockerfile, if you want the flexibility to publish the ports, you'll need to use the -P opting with docker run. Like so:
docker run -P your_app