Question 35 of 511
Modules and PackageshardMultiple ChoiceObjective-mapped

Quick Answer

The answer is to update the commit hash or use a version tag pointing to the latest, then rebuild the Docker image with the --no-cache flag. This is necessary because when a Docker image is built, pip installs the package from the Git repository at the specific commit hash listed in the requirements file, and Docker’s layer caching can reuse an old cached layer containing the previous version of the package, even if the requirements file appears updated. Simply restarting the container does not rebuild the image, so the old installed package persists. On the PCAP exam, this scenario tests your understanding of how pip editable packages interact with Docker’s build cache, a common trap where candidates assume restarting a container refreshes dependencies. Remember the key distinction: container restarts do not rebuild images; only a fresh build with --no-cache forces pip to re-fetch the latest code from Git. Memory tip: “Cache is the culprit—no-cache is the cure.”

PCAP Modules and Packages Practice Question

This PCAP practice question tests your understanding of modules and packages. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

You are a DevOps engineer managing a Python application that consists of multiple microservices. One microservice, 'data_processor', imports a shared library 'common_lib' which is also used by other microservices. The shared library is developed in a separate repository and is installed via pip in each microservice's virtual environment as an editable package (pip install -e). Recently, you updated 'common_lib' with new functions, but when you redeploy 'data_processor' (by restarting the container), the new functions are not available; the old version is still used. The container uses a Docker image built from a requirements file that specifies 'common_lib' from a Git repository. You verify that the Git commit hash in the requirements file points to the latest version. What is the most likely cause and what is the correct course of action?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "most likely"

    Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Update the commit hash or use a version tag that points to the latest, and rebuild the Docker image without using cache (--no-cache).

When a Docker image is built, pip installs the package from the Git repository at the commit hash specified in the requirements file. Even if the requirements file points to the latest commit, Docker's layer caching may reuse a previously built layer that contains the old version of the package. Rebuilding the image with --no-cache forces Docker to re-execute the pip install step, fetching the latest code from Git and installing the updated common_lib. Simply restarting the container does not rebuild the image, so the old installed package persists.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Add the common_lib source directory to sys.path in the microservice code.

    Why it's wrong here

    Would not help because the package is already installed; it's the version that's outdated.

  • Rename the package in the requirements file to force a fresh install.

    Why it's wrong here

    Renaming is unnecessary and creates confusion.

  • Update the commit hash or use a version tag that points to the latest, and rebuild the Docker image without using cache (--no-cache).

    Why this is correct

    Ensures pip installs the latest version of common_lib.

    Clue confirmation

    The clue word "most likely" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Change the Python interpreter to a different version.

    Why it's wrong here

    Not relevant to the issue.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Python Institute often tests the misconception that restarting a container or redeploying without rebuilding the image will pick up changes from a Git-based pip dependency, when in fact the package is frozen in the image layer until the image is rebuilt with a fresh pip install.

Trap categories for this question

  • Similar concept trap

    Renaming is unnecessary and creates confusion.

Detailed technical explanation

How to think about this question

Docker build layers are cached based on the Dockerfile instructions and the content of files copied into the build context. If the requirements.txt file content (including the commit hash) has not changed, Docker may reuse the cached layer from a previous build where pip install was executed, even if the remote Git repository has new commits. Using --no-cache ensures that every instruction is re-executed, forcing pip to fetch the latest code from the Git URL. In CI/CD pipelines, it is common to use a version tag or a dynamic commit hash in the requirements file to avoid this caching issue.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A company's IT admin needs to give a contractor read-only access to production logs without sharing account credentials. Using role-based access control (RBAC) and temporary scoped permissions — not a permanent shared password — is the correct pattern. Questions like this test whether you can apply least-privilege access across cloud identity services.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PCAP practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free PCAP practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PCAP question test?

Modules and Packages — This question tests Modules and Packages — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Update the commit hash or use a version tag that points to the latest, and rebuild the Docker image without using cache (--no-cache). — When a Docker image is built, pip installs the package from the Git repository at the commit hash specified in the requirements file. Even if the requirements file points to the latest commit, Docker's layer caching may reuse a previously built layer that contains the old version of the package. Rebuilding the image with --no-cache forces Docker to re-execute the pip install step, fetching the latest code from Git and installing the updated common_lib. Simply restarting the container does not rebuild the image, so the old installed package persists.

What should I do if I get this PCAP question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "most likely". Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Keep practising

More PCAP practice questions

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.