Which command demonstrates exposing port 8080 on the host to port 80 inside the container?

Prepare for the Red Hat OpenShift Developer II DO288 Exam with our quizzes. Study with flashcards and multiple choice questions, each with hints and explanations. Get ready for your certification!

Multiple Choice

Which command demonstrates exposing port 8080 on the host to port 80 inside the container?

Explanation:
Port mapping with the -p flag maps a host port to a container port using the format hostPort:containerPort. To expose host port 8080 to container port 80, you need -p 8080:80. The command shown uses -p 8080:80, runs in detached mode, assigns a name, and specifies the image, which together accomplish the exact mapping described. Other options either swap the ports (host 80 to container 8080), map the same port on both ends (8080:8080), or bind a specific localhost address and a different host port (127.0.0.1:8081:80), which do not meet the requirement of host 8080 to container 80.

Port mapping with the -p flag maps a host port to a container port using the format hostPort:containerPort. To expose host port 8080 to container port 80, you need -p 8080:80. The command shown uses -p 8080:80, runs in detached mode, assigns a name, and specifies the image, which together accomplish the exact mapping described. Other options either swap the ports (host 80 to container 8080), map the same port on both ends (8080:8080), or bind a specific localhost address and a different host port (127.0.0.1:8081:80), which do not meet the requirement of host 8080 to container 80.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy