Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
GimmeJob
Sign in
Docker & containers · Chapter 16 / 16

Docker & containers

Capstone and command reference

Outcomes

Prove that you can build, explain, run, test, replace and diagnose a complete application. This local exercise uses a Python API, SQLite volume and separate checker; it intentionally requires no cloud account, registry login or external application dependency.

Files and behavior

Get the repository example. If starting without a checkout:

git clone https://github.com/sergiiiavt/gimme-job.git
cd gimme-job/examples/docker-learning
FilePurpose
app.pyHTTP API, transactional counter, health and graceful shutdown
checks.pyAPI assertions executed from another container
DockerfileNon-root image and health check
.dockerignoreExplicitly limited build inputs
compose.yamlServices, loopback publication, volume and restrictions
test_capstone.pyApplication tests without a Docker dependency

GET /health checks a database read, GET /counter reads the value, and POST /counter increments it. Unknown GET/POST routes return JSON 404. The health probe does not mutate data or prove that every future write will succeed. The unauthenticated API and Python standard-library HTTP server are for local learning.

Build, test and replace

From the example directory:

docker compose config --quiet
docker compose up --build -d --wait --wait-timeout 90
docker compose --profile checks run --rm --no-deps checks
curl --fail http://127.0.0.1:18080/counter
docker compose up -d --force-recreate --wait --wait-timeout 90 api
docker compose --profile checks run --rm --no-deps checks --require-existing

Both checker runs must exit 0. The second must find an existing nonzero counter after replacement. The first build needs access to the base-image registry. If the host port is occupied, choose another DOCKER_COURSE_PORT; the internal API address remains unchanged.

Inspect the restrictions

docker compose exec api id
docker compose exec api python -c "from pathlib import Path; Path('/app/write-test').write_text('blocked')"
docker compose logs --tail 30 api

Expect UID 10001. The write into /app must fail because the root filesystem is read-only. API writes to /data should still work. Explain why dropping capabilities, enabling no-new-privileges, bounding processes and selecting a rotated logging driver are useful without claiming they prove complete security.

Recovery exercise

Create a consistent SQLite backup using the storage chapter's commands. Read the copy, restore into a separate disposable environment with correct ownership, and verify the counter. Do not overwrite the original volume during the rehearsal.

Stop with docker compose down; start again and confirm the retained data. Use down --volumes only for an intentional reset of this exercise's data. Distinguish image removal, container removal and volume deletion in your explanation.

Command reference

TaskCommand
Daemon and contextdocker info, docker context show
Images and diskdocker image ls, docker system df
Resolved modeldocker compose config --quiet
Start and waitdocker compose up -d --wait
State and logsdocker compose ps -a, docker compose logs --tail 50 api
Run a checkerdocker compose --profile checks run --rm --no-deps checks
Replace APIdocker compose up -d --force-recreate --wait api
Stop and remove stackdocker compose down

The checker command assumes the API is already healthy. Verify context and project before any command that changes or removes resources.

Completion checkpoint and answer

Task: Explain a failed readiness probe, prove that data survives replacement, identify the actual user and writable paths, then describe a safe release and rollback.

Answer criteria: Evidence includes health/log output, successful container-level checks before/after replacement, UID/mount inspection, an identified release artifact, tested recovery and schema compatibility. Add a real server, authentication, TLS, off-host backups and monitoring before adapting the design for public production use.

Summary

You have completed the path when you can explain both a working run and its failure modes. Continue with the existing Cloud & DevOps path, networking or test automation according to the system you need to build or verify.

Source registry

4 chapter references
Docker Compose overview

Compose model, current plugin commands and multi-container application management.

Docker · official documentation
Source ↗
Docker volumes

Volume lifecycle, initialization, backup and restore responsibilities.

Docker · official documentation
Source ↗
Running containers

Container process, mounts, users, resource flags and exit status semantics.

Docker · official documentation
Source ↗
GimmeJob Docker capstone source

Complete API, Dockerfile, Compose configuration and executable checks used in the course.

GimmeJob repository · implementation
Source ↗