DockerImage Creation, Management, and Registry

Add & Copy — DCA Practice Question

A representative Docker Certified Associate (DCA) exam question on Add & Copy. Work through it below, then read why each option is right or wrong.

This question is part of the free Docker Certified Associate practice test.

Short answer

The correct answer is B. The unpacked contents of the archive, because ADD extracts local tar archives by default.

The correct answer is B. The unpacked contents of the archive, because ADD extracts local tar archives by default. A is wrong because ADD unpacks a local tar archive by default, while COPY leaves it packed. C is wrong because ADD accepts local files and URLs alike, not URLs only. D is wrong because extraction is the default for local archives, and no --extract flag is required.

The Question

A Dockerfile contains the line ADD app.tar.gz /opt/app/ and app.tar.gz is a gzip-compressed tar archive in the build context. What does the build place in /opt/app/?

AThe archive file itself as app.tar.gz, because ADD copies local files without changing them
BThe unpacked contents of the archive, because ADD extracts local tar archives by defaultCorrect
CAn empty directory, because ADD only accepts URLs and ignores local files in the build context
DThe archive file itself, unless the instruction is changed to ADD --extract app.tar.gz

Why B is correct

The correct answer is B. The unpacked contents of the archive, because ADD extracts local tar archives by default. A is wrong because ADD unpacks a local tar archive by default, while COPY leaves it packed. C is wrong because ADD accepts local files and URLs alike, not URLs only. D is wrong because extraction is the default for local archives, and no --extract flag is required.

Why the other options are wrong

Option A: The archive file itself as app.tar.gz, because ADD copies local files without changing them

Option A does not satisfy the requirement in the scenario. Review the explanation above: the correct choice (B) is the only one that fully meets every constraint stated in the question.

Option C: An empty directory, because ADD only accepts URLs and ignores local files in the build context

Option C does not satisfy the requirement in the scenario. Review the explanation above: the correct choice (B) is the only one that fully meets every constraint stated in the question.

Option D: The archive file itself, unless the instruction is changed to ADD --extract app.tar.gz

Option D does not satisfy the requirement in the scenario. Review the explanation above: the correct choice (B) is the only one that fully meets every constraint stated in the question.

Key idea: Add & Copy

The correct answer is B. The unpacked contents of the archive, because ADD extracts local tar archives by default. A is wrong because ADD unpacks a local tar archive by default, while COPY leaves it packed. C is wrong because ADD accepts local files and URLs alike, not URLs only. D is wrong because extraction is the default for local archives, and no --extract flag is required. On the DCA exam, questions in the "Image Creation, Management, and Registry" domain test whether you can map a scenario's constraints to the right choice. Read the requirement carefully, eliminate options that violate any single constraint, and pick the one that satisfies all of them with the least operational overhead.

Ready to see how you'd score?

Take the free practice quiz and find out which Docker Certified Associate domains you need to focus on. No signup required.

Practice 5 similar questions

Same cert, same or adjacent domain. Use these after reviewing the explanation.

Related Docker Certified Associate Practice Questions

Official sources used

Verify program and exam details at the source before scheduling.