CompTIA Linux+ (XK0-005) — Question 111
A Linux administrator was asked to run a container with the httpd server inside. This container should be exposed at port 443 of a Linux host machine while it internally listens on port 8443. Which of the following commands will accomplish this task?
Answer options
- A. podman run -d -p 443:8443 httpd
- B. podman run -d -p 8443:443 httpd
- C. podman run –d -e 443:8443 httpd
- D. podman exec -p 8443:443 httpd
Correct answer: A
Explanation
The correct command is A, as it properly maps port 443 on the host to port 8443 inside the container, allowing external access to the httpd server. Option B reverses the mapping, exposing the container's port 443 instead, which is not the requirement. Option C incorrectly uses the '-e' flag, which is for environment variables, not port mapping. Option D uses 'exec' instead of 'run', which is not suitable for starting a new container.