Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
You have a server named Server1 that runs Windows Server 2019. Server1 is a container host.
You are creating a Dockerfile to build a container image.
You need to add a file named File1.txt from Server1 to a folder named C:\Folder1 in the container image.
Solution: You add the following line to the Dockerfile.
Copy-Item File1.txt C:\Folder1\File1.txt
You then build the container image.
Does this meet the goal?
Click on the arrows to vote for the correct answer
A. B.B
Copy is the correct command to copy a file to the container image.
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy https://docs.docker.com/engine/reference/builder/The provided solution will not meet the stated goal.
The solution provided in the question is incorrect because the Copy-Item
cmdlet is a PowerShell cmdlet and is not compatible with Dockerfile syntax. Dockerfile uses its own syntax for copying files and directories.
To add a file from the host to a folder in the container image, the Dockerfile syntax COPY
or ADD
can be used. In this case, to copy File1.txt from Server1 to C:\Folder1 in the container image, the correct line to add to the Dockerfile would be:
sqlCOPY File1.txt C:\Folder1\
This line should be added to the Dockerfile before building the container image.
Therefore, the correct answer to the question is B. No, the solution provided does not meet the goal.