Developing Applications and Automating Workflows Using Cisco Platforms (DEVASC) — Question 104
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?
Answer options
- A. docker build -p 8080:80 alpine:latest
- B. docker exec -p 8080:80 alpine:latest
- C. docker start -p 8080:80 alpine:latest
- D. docker run -p 8080:80 alpine:latest
Correct answer: D
Explanation
The correct command is 'docker run -p 8080:80 alpine:latest' because it is specifically designed to create and start a container from an image. The other options are incorrect because 'docker build' is used to create an image, 'docker exec' runs a command in an existing container, and 'docker start' only starts an already created container without the capability to bind ports.