docker -p

docker run -it -p 5000:80 --name mynginx nginx is no problem to start like this, because nginx is started on port 80;
you can access nginx by curl http:// hostip :5000

docker run -it -p 5000:1234 --name mynginx nginx because 1234 does not have an app listening
here, curl http://host ip:5000 cannot access nginx This is because port 1234 in the container is not monitored

Dockerfile expose just means that the app may be started on this port, and the actual port on which the app is started shall prevail, which is generally accurate;

The docker run -p parameter is to map the port in the container to the port of the host; the port of the host can be used to access the mapped port in the container

Guess you like

Origin blog.51cto.com/searchcoding/2546114