DevOps Tools Engineer (LPIC-OT 701) — Question 6

Given the following excerpt of a Dockerfile:
Run apt-get ""y update && apt-get install ""y fortunes && apt-get clean
Why are the multiple apt-get commands combined in one RUN statement instead of using multiple RUN statements?

Answer options

Correct answer: D

Explanation

The correct answer is D because combining the commands in a single RUN instruction allows them to execute in the same container instance, thus preventing Docker from reverting to the original base image after each RUN. The other options are incorrect as they misinterpret how Docker handles command execution, parallelism, and image creation.