Docker and Kubernetes for Developers
Question — of 36
Assessment

Docker and Kubernetes for Developers

Answer all 36 questions to test your understanding. Your results will be shown at the end.

36
Questions
12
Objectives
80%
Pass mark
1
Single Choice

An API listens on 127.0.0.1:3000 inside its container. The container starts successfully with `docker run -p 8080:3000 api`, and an HTTP request made inside the container succeeds, but a request to localhost:8080 on the Docker host fails.

Which change directly addresses the demonstrated problem?

Docker Request Path A host request to localhost port 8080 passes through Docker's published port mapping to the container's eth0 interface on port 3000. The API listener is shown separately at container loopback address 127.0.0.1 port 3000. Docker Request Path Host client localhost:8080 Docker mapping 8080 → 3000 Container eth0 172.18.0.2 :3000 API listener 127.0.0.1:3000 loopback
  • AAdd `EXPOSE 8080` to the Dockerfile and rebuild.
  • BChange the publication to `-p 3000:8080`.
  • CConfigure the API to listen on 0.0.0.0:3000.
  • DRun the container with a user-defined bridge network.
✓ Answer recorded
2
Select All That Apply

A developer builds an image successfully and starts it with `-p 8080:3000`. Docker reports that the container is running, but the acceptance criteria require a successful response on the published port and all supplied smoke tests to pass.

Which checks provide necessary acceptance evidence beyond the successful build and running state? Select all that apply.

  • Call the expected HTTP endpoint through host port 8080 and check its response.
  • Confirm that the Dockerfile declares `EXPOSE 3000` before accepting the service.
  • Execute the complete supplied smoke suite against the running application.
  • Verify that Docker marks the image's declared ports as published in its metadata.
✓ Answer recorded
3
Sequencing

A clean workstation has application source and a Dockerfile but no application image or running container. The acceptance script requires the response from a published-port check to succeed before it launches the smoke suite.

Order the steps to produce acceptance evidence for the newly built application.

⠿Run the supplied smoke suite against the published application endpoint.
⠿Start a container from that image with the required host-to-container port mapping.
⠿Build the application image from the Dockerfile.
⠿Check the expected response through the published host port.
✓ Answer recorded
4
Select All That Apply

A Node application image is 1 GB and includes its compiler toolchain, local node_modules directory, and Git history. Its Dockerfile copies the entire repository before installing dependencies, so changing one source file reruns dependency installation.

Which changes address the observed problems without relying on skipped application tests? Select all that apply.

Container Build Trace A repository passes through dockerignore filtering into a builder stage. Dependency manifests feed installation before source compilation. Artifacts pass into a separate runtime stage. File counts, sizes, timings, cache observations, and application test counts accompany the stages. Container Build Trace Repository 842 MB 6,240 files .dockerignore 118 MB 910 files Builder Manifests → deps 74 s · cache 2/8 Source → compile 21 s Runtime Artifacts 186 MB App tests: 0/42
  • Install dependencies before copying frequently changed application source.
  • Keep the toolchain and remove its files in a separate final RUN instruction.
  • Exclude local node_modules and Git history from the build context.
  • Copy required runtime artifacts into a separate runtime build stage.
✓ Answer recorded
5
Single Choice

A baseline image is 900 MB. Candidate A is 610 MB and passes every provided test; candidate B is 560 MB but fails the PDF export test because a runtime library was omitted.

Which acceptance decision is justified by the size and test requirements?

  • AAccept A; it exceeds the required reduction and preserves tested behavior.
  • BAccept B; removing an optional library is a valid size optimization.
  • CReject both; a 30% reduction requires an image smaller than 600 MB.
  • DReject both; A retains about 68% of the baseline rather than at most 30%.
✓ Answer recorded
6
Fill in the Blank

A Dockerfile downloads a 400 MB compiler in one RUN instruction and deletes it in a later RUN instruction. The final filesystem no longer shows the compiler, but the distributed image remains large.

The deletion does not recover those distributed bytes because the compiler remains stored in earlier ___.

The deletion does not recover those distributed bytes because the compiler remains stored in earlier  .
✓ Answer recorded
7
Single Choice

A Compose project defines services named `app` and `db` on its default network. PostgreSQL listens on container port 5432 and is published as `15432:5432`; the app's connection string currently uses localhost:15432.

Which database address should the app container normally use?

Compose Network and Port Mapping Compose Network and Port Mapping Compose network app container Attempt: localhost:15432 db container Listening port: 5432 Docker host · 15432 → 5432
  • Alocalhost:5432
  • Bdb:15432
  • Chost.docker.internal:5432
  • Ddb:5432
✓ Answer recorded
8
Select All That Apply

A Compose database stores its data in a named volume, and the app uses `depends_on: [db]`. On cold starts the app sometimes exits before the database accepts connections; the team also needs evidence that records survive database-container recreation.

Which actions directly strengthen startup reliability or establish persistence evidence? Select all that apply.

  • Add connection retries with bounded backoff to the application.
  • Rely on the existing short-form depends_on to wait for SQL readiness.
  • Insert a record, recreate the database container with its volume retained, and read it.
  • Add a meaningful database healthcheck and use a service_healthy dependency.
✓ Answer recorded
9
Assertion–Reason

A database uses a non-external named volume declared in compose.yaml. A developer proposes testing container recreation by running `docker compose down -v` followed by `docker compose up`.

Assertion: This procedure should preserve the existing database records because the storage uses a named volume. Reason: The `-v` option removes named volumes declared by the Compose project, except external volumes.

  • ABoth A and R are true and R is the correct explanation of A
  • BBoth A and R are true but R is NOT the correct explanation of A
  • CA is true but R is false
  • DA is false but R is true
✓ Answer recorded
10
Select All That Apply

An image runs as root, contains an API key copied into an earlier layer, and has a critical OS vulnerability with a patched package available. The API key has already been pushed to a shared registry.

Which actions address these findings rather than merely hiding them? Select all that apply.

Deployment Security Review A security review branches to three findings: a runtime running as root, a credential in an earlier image layer, and a critical dependency vulnerability with a published fixed version. Animated packets associate each finding with its affected component. Deployment Security Review Security review Build 184 · 3 findings Runtime · pod api-7 UID 0 · user root Image · service:v1.8 Credential · layer 3 of 8 Dependency · package-x 4.2.0 Critical · fixed in 4.2.3
  • Rotate the exposed key and rebuild without embedding its replacement.
  • Delete the key in a final RUN instruction and keep using its current value.
  • Configure a non-root runtime user and grant only required filesystem access.
  • Update the vulnerable component, rebuild, and confirm the finding is resolved.
✓ Answer recorded
11
Match the Pairs

Four hardening checks reveal a UID 10001 process unable to write uploads, a revoked credential still present in image history, a fixable critical library embedded in the application binary, and a scanner report generated before the latest rebuild.

Match each finding to the most directly relevant corrective action.

Concept
UID 10001 cannot write the application's upload directory.
A revoked credential remains recoverable from image history.
A vulnerable library is statically embedded in the application binary.
The scanner report predates the image being proposed for release.
Definition
Rebuild without the credential-bearing layer and replace the distributed artifact.
Scan the exact rebuilt image digest intended for release.
Update the application dependency and recompile the binary.
Give the runtime user appropriate ownership or narrowly scoped write permission.
0 of 4 pairs matched
✓ Answer recorded
12
Single Choice

A developer switches to a minimal image and removes its package manager. The supplied scanner still reports a critical vulnerability in an installed TLS library and identifies a fixed version.

What is the strongest next step before declaring the image compliant?

  • ASuppress the finding because the container cannot install additional packages.
  • BRebuild with the patched library, rerun tests, and scan the release digest.
  • CAccept the finding because a minimal base image has a smaller attack surface.
  • DDisable the library's command-line tools while retaining the same library.
✓ Answer recorded
13
Single Choice

A Deployment has three Ready Pods labeled `app: catalog`. A ClusterIP Service selects `app: shop`; an in-cluster test client resolves the Service name but cannot reach the application.

Which change addresses the demonstrated routing defect?

Catalog Service routing A test client resolves the catalog Service. The Service selector is app=shop. Three Ready Deployment Pods have the label app=catalog. A packet moves from the client to the Service. Catalog Service routing Test client DNS: catalog Service: catalog selector: app=shop Deployment Pods app=catalog Ready: 3/3
  • ASet the Service selector to `app: catalog`.
  • BRestart the Pods so the Service rediscovers their endpoints.
  • CChange the Service type from ClusterIP to NodePort.
  • DSet the Service port equal to the application's containerPort.
✓ Answer recorded
14
Match the Pairs

An API must run three replicas, listen inside each Pod on 8080, and be reachable through a Service on port 80. Its Pods carry the label `app: inventory`, and their readiness check can fail while the process remains running.

Match each intended outcome to the manifest setting or evidence that directly establishes it.

Concept
Request three managed application replicas.
Forward Service port 80 to the application's listener on 8080.
Associate the Service with inventory Pods.
Establish that all three replicas currently satisfy readiness.
Definition
Set the Service selector to match app: inventory.
Inspect readyReplicas or each Pod's Ready condition.
Set the Deployment's spec.replicas to 3.
Set the Service's port to 80 and targetPort to 8080.
0 of 4 pairs matched
✓ Answer recorded
15
Select All That Apply

kubectl apply succeeds for a Deployment and Service. The acceptance criteria require three ready replicas and a successful HTTP response from a test client running in the same namespace.

Which observations directly support those acceptance criteria? Select all that apply.

  • The API server returned created or configured for both manifests.
  • The Deployment reports three ready replicas from the intended workload.
  • The Service has an allocated ClusterIP address.
  • The test client receives the expected response through the Service.
✓ Answer recorded
16
Select All That Apply

A Deployment reads a feature flag from a ConfigMap environment variable and a password from a Secret environment variable. A teammate proposes committing the Secret manifest because its data field contains base64 rather than plain text.

Which conclusions are justified? Select all that apply.

Pod Startup and API Object Snapshots At time zero, a ConfigMap flag and Secret password supply a Pod's environment variables. A later API-object snapshot and the running application's environment are shown separately at time thirty. Pod Startup and API Object Snapshots API objects · t=0 ConfigMap: flag=off Secret: pwd=v1 Pod start · t=0 env: FLAG=off env: PWD=v1 App · t=30 env: FLAG=off env: PWD=v1 API objects · t=30 ConfigMap: flag=on · Secret: pwd=v2
  • The encoded password remains sensitive and should not be committed in that form.
  • Changing either API object does not update these variables in existing processes.
  • Secret environment variables are encrypted inside the application's process memory.
  • Consumption checks should prove use without printing the password into CI logs.
✓ Answer recorded
17
Fill in the Blank

A ConfigMap-backed environment variable was changed, but an existing Deployment's containers still report the previous value. The Pod template has not changed, and the team wants kubectl to replace the Pods without changing the replica count.

The kubectl operation `kubectl ___ deployment/catalog` initiates this replacement.

The kubectl operation `kubectl   deployment/catalog` initiates this replacement.
✓ Answer recorded
18
Assertion–Reason

A team injects a database password through a Secret reference rather than embedding it in a Deployment manifest. A developer claims that this choice automatically makes storing the base64 Secret manifest in Git safe.

Assertion: Using a Secret reference keeps the literal password out of the Deployment manifest. Reason: Kubernetes Secret data encoded with base64 is encrypted and therefore safe to commit.

  • ABoth A and R are true and R is the correct explanation of A
  • BBoth A and R are true but R is NOT the correct explanation of A
  • CA is true but R is false
  • DA is false but R is true
✓ Answer recorded
19
Match the Pairs

An API needs 90 seconds to initialize, sometimes loses a required dependency after startup, and can deadlock while its process stays alive. The team also wants existing in-flight requests to finish when a Pod is terminated.

Match each condition to the mechanism that most directly addresses it.

Concept
Initialization needs time before normal health checks should run.
The API temporarily cannot serve valid requests but can recover.
The API is deadlocked and needs a container restart.
In-flight requests should finish during Pod termination.
Definition
Use a startup probe with a sufficient failure budget.
Fail liveness after the configured failure threshold.
Use graceful application shutdown and adequate termination grace time.
Fail readiness so normal Service traffic is withheld.
0 of 4 pairs matched
✓ Answer recorded
20
Single Choice

A controlled test makes a Pod's readiness endpoint fail while its liveness endpoint continues succeeding. The Pod stays Running, its restart count remains unchanged, and after endpoint propagation it receives no new requests through a normal Service.

How should the team interpret this result?

Probe and Workload Observations Readiness probe HTTP 503 Pod / Service Ready = false Normal Service endpoints: 3 → 2 Liveness probe HTTP 200 Container State: Running Restart count: 1 → 1
  • ALiveness is ineffective because an unready container should always restart.
  • BReadiness has not taken effect because the Pod's phase is still Running.
  • CReadiness has triggered a restart that is waiting for the liveness threshold.
  • DReadiness is working; traffic eligibility and container restart are separate.
✓ Answer recorded
21
Assertion–Reason

An application takes up to two minutes to initialize. It has a startup probe with an adequate budget plus separate readiness and liveness probes.

Assertion: Liveness failures cannot restart the container while its startup probe is still pending within its allowed budget. Reason: When configured, a startup probe must succeed before Kubernetes begins liveness and readiness probing.

  • ABoth A and R are true and R is the correct explanation of A
  • BBoth A and R are true but R is NOT the correct explanation of A
  • CA is true but R is false
  • DA is false but R is true
✓ Answer recorded
22
Single Choice

A database Pod mounts a bound PVC at /mnt/data, but the database configuration writes its files to /var/lib/database. After deleting and recreating only the Pod, the test records are gone even though the original PVC still exists.

Which correction most directly addresses the observed loss?

Storage State Across Pod Replacement Storage State Across Pod Replacement Pod A · container layer /var/lib/database 248 records Pod B · container layer /var/lib/database 0 records PVC data-01 · /mnt/data 0 records PVC data-01 · /mnt/data 0 records
  • AChange the volume's reclaim policy from Delete to Retain.
  • BMount the PVC at the actual data directory or configure the database to use it.
  • CReplace the PVC with an emptyDir mounted at /var/lib/database.
  • DSet the container's workingDir to /mnt/data so database writes use the volume.
✓ Answer recorded
23
Select All That Apply

A single-replica database uses a PVC mounted at its configured data directory. The team must demonstrate persistence across Pod replacement without accidentally testing deletion of the storage itself.

Which steps or conclusions are appropriate? Select all that apply.

  • Record a test row, delete only the Pod, and read that row from its replacement.
  • Delete the PVC as well, since a bound volume always survives claim deletion.
  • Confirm that the replacement uses the same claim and the intended data directory.
  • Treat a Bound PVC as sufficient evidence that the application stored its records there.
✓ Answer recorded
24
Fill in the Blank

A database writes to /var/lib/postgresql/data, but a PVC is attached at /backup and receives no database writes. The developer wants to correct the container's volumeMount entry rather than change the database's data directory.

The volumeMount field that must be changed to /var/lib/postgresql/data is ___.

The volumeMount field that must be changed to /var/lib/postgresql/data is  .
✓ Answer recorded
25
Select All That Apply

Each application Pod requests 200m CPU, has a 1000m CPU limit, and currently consumes 150m. An HPA targets 60% average CPU utilization, and its metrics are available.

Which interpretations are correct for this CPU utilization target? Select all that apply.

Per-Pod CPU measurements and settings 1000 500 0 200 millicores 170 millicores 150 millicores 1000 millicores Request Usage (prior) Usage (now) Limit
  • The measured utilization is 15%, because the CPU limit is the denominator.
  • The measured utilization is 75%, relative to the CPU request.
  • Sustained measurements can recommend scale-out even below the CPU limit.
  • Changing CPU requests can change scaling behavior without changing actual CPU use.
✓ Answer recorded
26
Match the Pairs

During a load test, engineers observe CPU throttling near a container's CPU limit, OOMKilled restarts near its memory limit, Pending replicas with Insufficient cpu events, and delayed scale-in after traffic drops despite low CPU measurements.

Match each observation to its most directly relevant interpretation.

Concept
CPU throttling occurs near the configured CPU limit.
The container restarts with OOMKilled near its memory limit.
New replicas remain Pending with Insufficient cpu events.
Low CPU does not immediately reduce the HPA replica count.
Definition
Memory-limit enforcement can terminate the container.
Requested CPU cannot currently fit on eligible nodes.
Scale-down stabilization or configured scaling policies may delay reduction.
CPU enforcement can restrict execution time without killing the container.
0 of 4 pairs matched
✓ Answer recorded
27
Fill in the Blank

An HPA uses averageUtilization for CPU, and each Pod contains one application container. Metrics are available and CPU limits are set, but the controller reports that CPU utilization cannot be calculated because a required resource setting is missing.

The missing denominator for this utilization calculation is the container's ___.

The missing denominator for this utilization calculation is the container's  .
✓ Answer recorded
28
Assertion–Reason

A stateless API Deployment retains revision history and uses readiness probes. The team is planning a rollback exercise and a separate continuous-request test during its next rolling update.

Assertion: A rollout undo can restore the previous retained Deployment Pod template. Reason: Readiness probes help keep unready replacement Pods out of normal Service traffic during a rollout.

  • ABoth A and R are true and R is the correct explanation of A
  • BBoth A and R are true but R is NOT the correct explanation of A
  • CA is true but R is false
  • DA is false but R is true
✓ Answer recorded
29
Select All That Apply

A three-replica HTTP API must undergo a rolling update with no failed requests under the supplied workload. The cluster has spare capacity, and the application supports readiness reporting and graceful shutdown.

Which measures directly support the goal or establish that it was achieved? Select all that apply.

Requests During a Deployment Update A workload sends requests through a Service during a Deployment update. Pod B is created at zero seconds and becomes Ready at 2.1 seconds. Pod A receives SIGTERM at 2.4 seconds and drains twelve in-flight requests. The workload records 600 responses: 598 successful responses and two server errors, with no timeouts. Requests During a Deployment Update Workload · 600 requests 2xx 598 · 5xx 2 Timeouts 0 Window 0–5 s Service 600 requests Pod A · SIGTERM 2.4 s In-flight 12 → 0 Pod B · created 0.0 s Ready 2.1 s
  • Use maxUnavailable: 0 and a positive maxSurge with meaningful readiness checks.
  • Treat successful rollout status as proof that every client request succeeded.
  • Allow in-flight requests to drain within an adequate termination grace period.
  • Run the supplied continuous workload and record its failures across the update.
✓ Answer recorded
30
Sequencing

A completed update to v2 failed application acceptance, and revision 4 is the recorded v1 target. The exercise requires validating the rollback target before issuing the rollback, then waiting for completion before running restored-version acceptance checks.

Order the rollback procedure.

⠿Run rollout undo with --to-revision=4.
⠿Wait for rollout completion and confirm the replacement replicas are Ready.
⠿Check that the application reports v1 and passes the restored-version smoke tests.
⠿Inspect revision 4 and confirm its Pod template references the intended v1 image.
✓ Answer recorded
31
Match the Pairs

Four diagnostic observations are available: image-pull events report manifest unknown, startup logs reject an invalid DATABASE_URL, a Service has no EndpointSlice addresses and mismatched selectors, and a reachable Pod listens on 8080 while its Service targets 9090.

Match each observation to the root cause best supported by the evidence.

Concept
Image-pull events report manifest unknown for the requested image tag.
Application startup logs explicitly reject DATABASE_URL syntax.
Service selectors do not match Pod labels, and its EndpointSlices contain no addresses.
Direct Pod access succeeds on 8080, but the Service forwards to 9090.
Definition
The injected application configuration has an invalid connection-string value.
The referenced repository or image version is not available at that registry reference.
The Service is selecting no application Pods.
The Service targetPort does not match the application's listening port.
0 of 4 pairs matched
✓ Answer recorded
32
Single Choice

An application Pod repeatedly enters CrashLoopBackOff. Its current logs contain only the beginning of a new startup, while the last terminated container exited with code 1 after a configuration change.

Which next action most directly retrieves evidence about the previous failed application execution?

Application Container Execution Timeline Application Container Execution Timeline a7 · start 14:22:08 config v18 a7 · exit 1 14:22:11 log: DB timeout b8 · start 14:22:13 restart count: 1 b8 · logs 14:22:14 log: booting
  • ARun kubectl describe pod to retrieve the terminated application's error output.
  • BRun kubectl get events to retrieve the application's last logged exception.
  • CRun kubectl logs for the application container with --previous.
  • DRun kubectl logs with --since=1h to include earlier container instances.
✓ Answer recorded
33
Fill in the Blank

A Pod remains in ImagePullBackOff, and events report registry authentication failure. A valid registry credential Secret already exists in the Pod's namespace, but neither the Pod nor its ServiceAccount references it.

To attach that registry credential directly in the Pod specification, add its Secret name under ___.

To attach that registry credential directly in the Pod specification, add its Secret name under  .
✓ Answer recorded
34
Select All That Apply

A pipeline tests commit A, builds an image, pushes it as latest, applies a Deployment that still references latest, and immediately reports success. Another build can overwrite latest before the test namespace pulls the image.

Which changes close the artifact-identity or verification gaps? Select all that apply.

Image publication and test rollout Tested commit A produces image digest 7a1c. The registry publishes latest and captures that digest. A concurrent build from commit B publishes latest with digest 9b2e. The test namespace deploys latest and pulls 9b2e. Readiness reports three of three replicas and smoke tests report eighteen of twenty. Image publication and test rollout B · build 42 latest: 9b2e… Tested A · build 41 tests: 126/126 sha256:7a1c… Registry latest: 7a1c… capture: 7a1c… Deployment · test image: latest pull: 9b2e… Checks ready: 3/3 smoke: 18/20
  • Resolve the published image digest and deploy that exact digest.
  • Use imagePullPolicy: Always as the complete immutability guarantee.
  • Wait for rollout readiness and then run application smoke tests in the test environment.
  • Record the mapping from tested commit to image digest and deployment.
✓ Answer recorded
35
Single Choice

CI deploys a new digest to namespace test-a. The next step runs `kubectl rollout status deployment/api` without a namespace; its current context points to default, where an older api Deployment is healthy.

Which correction makes the readiness gate verify the intended deployment?

  • AAdd a longer timeout to the existing rollout status command.
  • BRun rollout status with --namespace=test-a and fail the job if it does not complete.
  • CReplace rollout status with a successful kubectl apply exit-code check.
  • DSet metadata.namespace to test-a in the manifest and leave the gate command unchanged.
✓ Answer recorded
36
Select All That Apply

A CI deployment uses an exact image digest and reaches three Ready replicas. Its smoke-test command then exits nonzero, but the shell step ends with `|| true`, leaving the workflow green.

Which changes or conclusions are justified? Select all that apply.

  • Treat Ready replicas as sufficient evidence and remove the smoke-test stage.
  • Propagate the smoke-test failure so this run cannot satisfy the deployment gate.
  • Use `set -e` before the existing command so the trailing `|| true` cannot mask failure.
  • Keep readiness and smoke tests because they establish different aspects of success.
✓ Answer recorded
0% SCORE
Assessment Complete
0
Correct
0
Incorrect
36
Total