QuestionQ375

Application Deployment and Security

Which two commands download and run an Apache web server container in Docker, with port 8080 in the container bound to port 80 on the host?

Choose two
  • A docker pull apache
  • B docker run –p 8080:80 httpd
  • C docker run –p 80:8080 httpd
  • D docker pull httpd
  • E docker pull https
Explanation

The official Apache web server image on Docker Hub is 'httpd', so you obtain it with 'docker pull httpd' (D). Docker's -p flag maps ports as hostPort:containerPort; to bind container port 8080 to host port 80 the correct form is 'docker run -p 80:8080 httpd' (C). Option B ('-p 8080:80') reverses the mapping (host 8080 to container 80), and options A/E reference nonexistent/incorrect images ('apache', 'https'). Hence C and D.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!