A Linux administrator is asked to run a container with an HTTP server that listens internally on port 8443 and is exposed at port 443.
Which of the following commands will accomplish this task?
Correct Answer: A. podman run -d -p 443:8443 httpd
Explanation (60–80 words):
The command podman run -d -p 443:8443 httpd runs a container in detached mode (-d) and publishes container port 8443 (where the HTTP server listens internally) to the host's port 443. This enables external clients to access the server through HTTPS on the standard port (443), while the application inside the container continues operating on port 8443. The -p option maps host ports to container ports in the format host:container.
Why other options are incorrect:
B. podman run -d -p 8443:443 httpd:
This reverses the correct port mapping. It exposes the container’s port 443 to the host’s 8443, which is the opposite of the requirement. Clients would need to connect to port 8443 on the host instead of 443.
C. podman run -e 443:8443 httpd:
The -e flag is used to set environment variables inside the container, not for port mapping. Using -e in this context will have no effect on the HTTP server’s port exposure and will not meet the stated requirement.
D. podman exec -p 8443:443 httpd:
The podman exec command is used to run a command inside an already running container. It does not support port mappings and cannot be used to expose or bind ports between the host and container.
Discover a range of courses designed to provide you with the knowledge and skills needed to excel in your chosen field.
You don’t need one month to study and pass your test.
With Prepsaret, it takes you a few days to grasp all the concepts needed to pass your exams