Docker and CI/CD · Middle · Question 3 of 75
Why combine apt-get update and apt-get install in one RUN?
- 1Separate
RUNinstructions can't access the network - 2
apt-getonly works when both commands share one shell - ✓Correct answer: A cached
updatelayer would install packages from a stale index
Explanation
If update is its own cached layer, a later change to the install line reuses an old package index. Also clean /var/lib/apt/lists in the same RUN.