exam questions

Exam AZ-303 All Questions

View all questions & answers for the AZ-303 exam

Exam AZ-303 topic 3 question 22 discussion

Actual exam question from Microsoft's AZ-303
Question #: 22
Topic #: 3
[All AZ-303 Questions]

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 File1.txt /Folder1/
You then build the container image.
Does this meet the goal?

  • A. Yes
  • B. No
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
Copy is the correct command to copy a file to the container image.
Reference:
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy https://docs.docker.com/engine/reference/builder/

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Azure_Az_U_Can_B
Highly Voted 4 years, 9 months ago
C:\Folder1/ is ALSO correct, but I think the aim of the question is to ensure people understand that the root drive letter (C:) is not required even though it is on Windows. Questions asks whether /Folder1/ will work, and the answer is yes, as BOTH syntaxes will work.
upvoted 23 times
kwaazaar
4 years, 4 months ago
Although it makes no sense to build images on the container host. That's why I thought they may have been after an answer that mounts the file in the container at runtime.
upvoted 1 times
...
...
pentum7
Highly Voted 4 years, 10 months ago
correct
upvoted 10 times
pentum7
4 years, 10 months ago
See https://markheath.net/post/transfer-files-docker-windows-containers technique #4
upvoted 1 times
pentum7
4 years, 8 months ago
link no longer works , so try this SO thread instead https://stackoverflow.com/questions/37789984/how-to-copy-folders-to-docker-image-from-dockerfile
upvoted 2 times
...
...
...
sandeepmalik
Most Recent 3 years, 4 months ago
In today's exam. Score 900+ Correct answer.
upvoted 1 times
...
shree178
3 years, 5 months ago
On exam today 19-2-2022.. Passed with 871.
upvoted 1 times
...
syu31svc
3 years, 11 months ago
Answer is Yes for sure https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile
upvoted 2 times
...
Red8aron
4 years ago
COPY File1.txt /Folder1/ and ADD File1.txt /Folder1/ will work ??
upvoted 3 times
edmacoar123
3 years, 8 months ago
Yes, ADD and COPY will work https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile#considerations-for-using-copy-with-windows https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile#considerations-for-running-add-with-windows
upvoted 1 times
...
...
lucascruzm
4 years ago
Corect answer.
upvoted 2 times
...
Alasmindas
4 years, 3 months ago
The answer is correct. It will work, key point of consideration is the drive letter C: is optional when you copy the file in docker image but the important point is that only "forward slash" i.e. "/" is valid, backslash ("\") is not valid in windows (it might be valid in Unix/Linux)
upvoted 2 times
...
luckyfriend
4 years, 5 months ago
Considerations for using COPY with Windows On Windows, the destination format must use forward slashes. For example, these are valid COPY instructions: Dockerfile Copy COPY test1.txt /temp/ COPY test1.txt c:/temp/
upvoted 5 times
...
sohailcharolia
4 years, 6 months ago
Considerations for using COPY with Windows On Windows, the destination format must use forward slashes. For example, these are valid COPY instructions: Dockerfile Copy COPY test1.txt /temp/ COPY test1.txt c:/temp/ Meanwhile, the following format with backslashes won't work: Dockerfile Copy COPY test1.txt c:\temp\
upvoted 4 times
...
PSngh
4 years, 8 months ago
correct format is fine https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy
upvoted 3 times
...
kcinofni
4 years, 8 months ago
Correct, https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile#considerations-for-using-copy-with-windows
upvoted 2 times
...
PieDev
4 years, 9 months ago
Should it not be C:\Folder1 ?
upvoted 1 times
edmacoar123
3 years, 8 months ago
Meanwhile, the following format with backslashes won't work: COPY test1.txt c:\temp\ https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile#considerations-for-using-copy-with-windows
upvoted 1 times
...
...
Az209co
4 years, 9 months ago
This is wrong. this format is used for linux machine and not for windows. the format has to be COPY File1.txt C:\Folder1\ <https://docs.docker.com/engine/reference/builder/>
upvoted 4 times
Jindrich
4 years, 9 months ago
On Windows, the destination format must use forward slashes - https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile
upvoted 7 times
...
edmacoar123
3 years, 8 months ago
Meanwhile, the following format with backslashes won't work: COPY test1.txt c:\temp\ https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile#considerations-for-using-copy-with-windows
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...