CompTIA Linux+ XK0-006 (V8) Practice Question

A development team builds a Python microservice with this Dockerfile:

FROM python:3.12-slim
WORKDIR /srv/app
RUN apt-get update && apt-get install -y build-essential
COPY . /srv/app
RUN pip install --no-cache-dir -r requirements.txt
ENTRYPOINT ["python", "main.py"]

When a single .py file is modified and docker build is re-run, the dependency-installation step executes again, adding several minutes to the build even though requirements.txt has not changed. Considering how image layers and the build cache behave, which revision will most effectively keep the dependency-installation layer cached so that only the application-code layer is rebuilt?

  • Copy requirements.txt in an earlier layer, run pip install -r requirements.txt, then copy the remainder of the application files.

  • Combine the apt-get and pip install commands into a single RUN instruction so they live in one layer.

  • Invoke docker build --pull to refresh the base image before every build.

  • Replace the ENTRYPOINT instruction with a CMD instruction to improve build caching.

CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Settings & Objectives
Random Mixed
Questions are selected randomly from all chosen topics, with a preference for those you haven’t seen before. You may see several questions from the same objective or domain in a row.
Rotate by Objective
Questions cycle through each objective or domain in turn, helping you avoid long streaks of questions from the same area. You may see some repeat questions, but the distribution will be more balanced across topics.

Check or uncheck an objective to set which questions you will receive.

Bash, the Crucial Exams Chat Bot
AI Bot