200-901 · Question #537
Refer to the exhibit. What is the result of running the Dockerfile?
The correct answer is C. Copy the directory app from the current directory of the Docker client, build it with make, and. The Dockerfile commands copy the application code from the local build context, build it using make, and then configure the image to execute the resulting application when a container starts.
Question
Refer to the exhibit. What is the result of running the Dockerfile?
Options
- ACopy the directory /app from the ubuntu:18.04 image, build it with make, and execute the
- BCopy the directory app from the current directory of the Docker client, execute the application with
- CCopy the directory app from the current directory of the Docker client, build it with make, and
- DCopy the /app directory from the ubuntu:18.04 image, execute the application with make, and
How the community answered
(14 responses)- C93% (13)
- D7% (1)
Why each option
The Dockerfile commands copy the application code from the local build context, build it using `make`, and then configure the image to execute the resulting application when a container starts.
The `COPY` instruction copies files from the build context, not from the `ubuntu:18.04` base image itself.
The Dockerfile typically includes a `RUN make` instruction to build the application, not just execute it directly after copying without a build step.
The `COPY app .` instruction copies the `app` directory from the Docker client's current directory (the build context) into the image. The `RUN make` command builds the application within the image, and the `CMD` instruction then executes the built application when a container is run from this image.
The `COPY` instruction copies from the build context (local directory), not from the `ubuntu:18.04` image's `/app` directory, and the `make` command is usually for building, not directly executing, the application.
Concept tested: Dockerfile build process
Source: https://docs.docker.com/reference/dockerfile/#copy
Topics
Community Discussion
No community discussion yet for this question.