Back to questionsWhat does
JuniorTheoryVery common
What does -p 8080:80 do in this command, and what changes without it?
docker run -d --name web -p 8080:80 nginx:1.27.3Docker forwards port 8080 of the host to port 80 inside the container, so localhost:8080 opens the nginx page. Without -p, nginx still listens on port 80 inside the container, but no port of the host leads to it.
- Reading
8080:80as container:host — the host port is always on the left - Expecting
EXPOSEin the Dockerfile to publish the port without-p
- What does
-p 127.0.0.1:8080:80change compared with-p 8080:80? - What does
docker run -Ppublish, and on which host ports?