nerdexam
Cisco

200-901 · Question #185

A local Docker alpine image has been created with an image ID of a391665405fe and tagged as "latest". Which command creates a running container based on the tagged image, with the container port…

The correct answer is D. docker run -p 8080:80 alpine:latest. docker run is the correct command because it creates AND starts a new container from an image in a single step. The -p host_port:container_port flag maps host port 80 to container port 8080, so the syntax -p 8080:80 maps container port 8080 to host port 80. The other commands…

Application Deployment and Security

Question

A local Docker alpine image has been created with an image ID of a391665405fe and tagged as "latest". Which command creates a running container based on the tagged image, with the container port 8080 bound to port 80 on the host?

Options

  • Adocker build -p 8080:80 alpine:latest
  • Bdocker exec -p 8080:80 alpine:latest
  • Cdocker start -p 8080:80 alpine:latest
  • Ddocker run -p 8080:80 alpine:latest

How the community answered

(30 responses)
  • A
    3% (1)
  • B
    7% (2)
  • D
    90% (27)

Explanation

docker run is the correct command because it creates AND starts a new container from an image in a single step. The -p host_port:container_port flag maps host port 80 to container port 8080, so the syntax -p 8080:80 maps container port 8080 to host port 80. The other commands are wrong: docker build builds images from Dockerfiles, docker exec runs a command inside an already-running container, and docker start restarts a stopped (already existing) container - none accept -p.

Topics

#Docker#Containerization#docker run#Port mapping

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice