Services and User Management
An administrator has created a user-defined bridge network named appnet. A web server must run in the background on that network, and clients on the LAN must reach it by connecting to port 8080 on the Docker host. The web server listens on port 80 inside the container. Which command meets this requirement?
Show the answer
Correct answerB. docker run -d --network appnet -p 8080:80 nginx
The -p option uses host_port:container_port, so 8080:80 publishes container port 80 on host port 8080. Reversing the values, as in 80:8080, would publish container port 8080 on host port 80, which does not match the web server's listening port.