Intermediate Docker & Containers
Q58 / 100

Why might "RUN apt-get update && apt-get install -y <package>" be written on a single RUN line rather than two separate RUN lines?

Correct! Well done.

Incorrect.

The correct answer is B) If "apt-get update" is cached from a previous build but the package list has changed upstream, a separate "apt-get install" could install outdated or missing packages; combining them ensures the update and install always run together as one cached unit

B

Correct Answer

If "apt-get update" is cached from a previous build but the package list has changed upstream, a separate "apt-get install" could install outdated or missing packages; combining them ensures the update and install always run together as one cached unit

Explanation

If "apt-get update" is its own cached layer, a later "apt-get install" might use a stale package index from the cached update step; chaining them with "&&" ensures both run together whenever either changes, avoiding "package not found" errors.

Progress
58/100