Skip to content
Aabha AI Academy

Stage 1 · L05

Read Git history and Docker lifetimes without confusing them

Core · original Session 1 plus essential local Git/Docker setup

Native checkpoint 01

Download starter · Download solution

Use the starter for this stage's focused examples. The cumulative transfer and solution belong at the stage-end capstone. Baseline checks pass; transfer checks initially fail. Downloads contain the matching native starter and solution for this stage.

Git records a reviewable source history. Docker records a packaged runtime; its containers are disposable processes. Learn both boundaries before the database lessons. Copy the starter to a learner workspace, initialize a local Git repository, add a .gitignore excluding .venv, .env, caches and data volumes, and commit a passing baseline. Never commit a database URL or a real email/API key.

After implementing availability, inspect git diff before committing. The diff should show the one route body you intended to change, not an entire environment or unrelated files. git status tells you which files are tracked, changed or untracked. A commit stores source state; it does not publish the website, run a CI service, create a Docker image or back up PostgreSQL data.

A Docker image is the filesystem/configuration template. A container is one running instance with its own lifecycle. Stopping a container stops its process; removing it deletes its writable layer. A named volume can outlive that removal. Stage 02 introduces a database volume deliberately so data can survive an app restart. A successful container start is not proof that the application is ready or that a migration ran.

Run docker version to check the daemon, not only the CLI binary. The revision runner uses --pull never, an internal network, owned resource names and a disposable PostgreSQL tmpfs. That fixture's data is intentionally deleted when the check ends. It is useful for learning tests and unsuitable as a persistent development database. The Compose example in stage 02 has a separate learner volume and explicit loopback binding.

Keep this local setup here in the core path. Branch reconciliation, PR review, Black/Pylint hooks and hosted CI belong to the later quality supplement. The simple local commit exercise is not a claim that any remote repository settings, required checks or merge protections have been configured.

Cloning creates a local repository with history, a working tree and an origin reference. It does not install packages, activate a venv, run migrations or copy an existing database. Staging chooses the exact changes for the next commit; git diff --cached reviews that selection. A container port also needs two deliberate boundaries: the server listens on its container interface, while a host-published port can bind only to loopback. The test runner publishes no app port; its TCP check is inside the isolated container.

Git commit: reviewed source state; Docker image: packaged runtime; Container: running process; Volume: separate stored data; A commit does not deploy. A; stopped app does not remove its DB; volume.
Git commit: reviewed source state; Docker image: packaged runtime; Container: running process; Volume: separate stored data; A commit does not deploy. A; stopped app does not remove its DB; volume.

Follow the running code

Focused lesson example; see the end-of-stage capstone for the cumulative app · stage 01

git init
git status
git diff
git add equipment/api.py
git diff --cached
# Commit only after the local baseline and transfer pass.
docker version

Predict and observe this focused example using the concepts explained above. Its boundary is stated in the focused answer.

Guided lab

  1. Read the explanation and predict the focused example’s outcome.
  2. In a learner copy, distinguish the working tree, staged change and commit. Explain which Docker resource keeps database data after container removal.
  3. Compare the observed outcome with the focused answer and state its boundary.

Expected: git diff shows unstaged edits; git diff --cached shows selected changes; a commit records the selected source revision. An image is a runtime template, a container is an instance, and a named volume has an independent lifetime. A source commit does not preserve that volume.

  • A missing daemon blocks Docker checks; a clean Git status does not prove the tests ran.

Focused exercise and answer

Complete this focused exercise before reading its answer. The full native transfer is introduced only at the end of the stage.

Your transfer task: In a learner copy, distinguish the working tree, staged change and commit. Explain which Docker resource keeps database data after container removal.

  1. In a learner copy, distinguish the working tree, staged change and commit. Explain which Docker resource keeps database data after container removal.
Inspect the matching answer

This answer addresses the focused exercise above; the cumulative implementation is shown only after the stage prerequisites.

git diff shows unstaged edits; git diff --cached shows selected changes; a commit records the selected source revision. An image is a runtime template, a container is an instance, and a named volume has an independent lifetime. A source commit does not preserve that volume.

Stage 01 capstone — after these prerequisites

Implement the read-only availability endpoint and preserve missing/invalid/method cases.

Use the downloaded starter after completing this stage's focused exercises. The cumulative implementation below is a stage transfer answer, not an answer to an earlier lesson.

python run_checks.py --stage 01 --role starter --prepare
python run_checks.py --stage 01 --role starter
python run_checks.py --stage 01 --role starter --transfer

From this extracted starter: preparation and baseline pass; transfer initially fails only at the named unfinished target. After implementing it, rerun the same starter --transfer command and expect success.

Optional comparison in a separate solution directory

Optional comparison: download and extract this stage’s solution ZIP into a separate directory. Change your terminal into that extracted solution root (beside checkpoint.json and run_checks.py) before running the following commands. Your starter remains a starter even after you implement its task.

python run_checks.py --stage 01 --role solution --transfer
Inspect the cumulative capstone implementation
@router.get("/{equipment_id}/availability")
def availability(equipment_id: int):
    item = get_equipment(equipment_id)
    return {"equipment_id": item["id"], "available": item["quantity"]}

Check your reasoning

Does deleting an app container delete a separate named database volume?

Show the explanation

No. Container, image and volume have separate lifetimes; remove a learner volume only when intentionally discarding its data.

Reading progress

54 lessons remain open to guests. Marking a lesson read records reading only; it does not award assessment credit or a certificate.

Device reading marks require browser storage. Reading is always available.

Sign in or create an account to save separate account progress. Your current page is kept.