Question
A Linux administrator needs to create and then connect to the app-01-image container. Which of the following commands accomplishes this task?
- A. docker run -it app-01-image Correct
- B. docker start -td app-01-image
- C. docker build -ic app-01-image
- D. docker exec -dc app-01-image
Explanation
docker run creates a new container from the image and starts it, and the -i (keep STDIN open) and -t (allocate a pseudo-terminal) options attach an interactive session to it. docker start only starts an existing container, docker build builds an image from a Dockerfile, and docker exec runs a command in a container that is already running, so none of them both create and connect.