CKAD · Domain 1 of 5 · 20% of the exam

CKAD Domain 1: Application Design and Build

40 free practice questions for Application Design and Build in the Certified Kubernetes Application Developer (CKAD) exam. Try each question first, then open "Show answer" for the correct option and explanation.

Application Design and Build practice questions

  1. Question 1. What does a multi-stage Dockerfile build let you do?

    1. Run several containers from one image at once
    2. Copy only the build output into a smaller final image
    3. Build images for several registries in parallel
    4. Split one image into layers stored on different nodes
    Show answer

    Answer: B. Copy only the build output into a smaller final image

    Earlier stages hold compilers and build tools. The final stage copies only the artifacts it needs (COPY --from=build), so the shipped image is smaller and has less attack surface.

  2. Question 2. A Pod spec sets command: ["python"] and args: ["app.py"]. Which Dockerfile instructions do these override?

    1. command overrides CMD; args overrides ENTRYPOINT
    2. command overrides ENTRYPOINT; args overrides CMD
    3. Both override RUN, which executes at container start
    4. Neither; the image's Dockerfile values always win
    Show answer

    Answer: B. command overrides ENTRYPOINT; args overrides CMD

    In Kubernetes, command replaces the image ENTRYPOINT and args replaces CMD. RUN only executes at build time.

  3. Question 3. What does the EXPOSE instruction in a Dockerfile do?

    1. Opens the port in the node's firewall
    2. Creates a Kubernetes Service for that port
    3. Documents the port the app listens on; it publishes nothing
    4. Forces the container to listen only on that port
    Show answer

    Answer: C. Documents the port the app listens on; it publishes nothing

    EXPOSE is metadata. Kubernetes doesn't need it: a Service or containerPort is what makes the port reachable.

  4. Question 4. A container image is referenced as myapp with no tag, and imagePullPolicy isn't set. Which pull policy applies?

    1. IfNotPresent
    2. Never
    3. Always
    4. OnFailure
    Show answer

    Answer: C. Always

    No tag means :latest, and for :latest (or no tag) the default pull policy is Always. OnFailure isn't a pull policy.

  5. Question 5. A container image is referenced as myapp:2.4.1, and imagePullPolicy isn't set. Which pull policy applies?

    1. IfNotPresent
    2. Always
    3. Never
    4. OnStart
    Show answer

    Answer: A. IfNotPresent

    For a specific tag other than :latest, the default is IfNotPresent: the kubelet uses a cached copy if the node has one.

  6. Question 6. Why pin an image by digest (myapp@sha256:...) instead of by tag?

    1. Digests make images download faster
    2. Kubernetes refuses to run images pulled by tag
    3. The digest always refers to exactly the same image content
    4. Digests encrypt the image layers in the registry
    Show answer

    Answer: C. The digest always refers to exactly the same image content

    Tags can be moved to a different image. A digest is a content hash, so every node runs the identical image.

  7. Question 7. Which command builds an image from the Dockerfile in the current directory and tags it web:1.0?

    1. docker run -t web:1.0 .
    2. docker build -t web:1.0 .
    3. docker commit web:1.0 .
    4. docker create --tag web:1.0 .
    Show answer

    Answer: B. docker build -t web:1.0 .

    docker build (or podman build) takes a build context, here '.', and -t sets the name and tag.

  8. Question 8. You must copy a built image to another machine as a tar file. Which command creates the file?

    1. docker export web:1.0 > web.tar
    2. docker push web.tar web:1.0
    3. docker image pack web:1.0 web.tar
    4. docker save -o web.tar web:1.0
    Show answer

    Answer: D. docker save -o web.tar web:1.0

    docker save writes an image with its layers and tags to a tar archive; docker load imports it. docker export works on containers and drops image metadata.

  9. Question 9. Which Dockerfile instruction makes the container's main process run as a non-root user?

    1. RUN chmod 1001 /app
    2. WORKDIR /home/1001
    3. USER 1001
    4. ENV UID=1001
    Show answer

    Answer: C. USER 1001

    USER sets the user (and optionally group) for later RUN instructions and for the container's process at runtime.

  10. Question 10. What is the purpose of a .dockerignore file?

    1. It excludes files from the build context sent to the builder
    2. It lists images the daemon should never pull
    3. It hides environment variables from docker inspect
    4. It skips failing instructions during a build
    Show answer

    Answer: A. It excludes files from the build context sent to the builder

    Excluding files such as .git, node_modules, or secrets keeps builds fast and stops them leaking into image layers.

  11. Question 11. Why are dependency installs usually placed before COPY of the application source in a Dockerfile?

    1. Because COPY must always be the last instruction
    2. So cached layers are reused when only the code changes
    3. So dependencies are installed as the root user
    4. Because RUN can't see files copied in earlier steps
    Show answer

    Answer: B. So cached layers are reused when only the code changes

    Each instruction is a cached layer. If the source changes but the dependency manifest doesn't, the slow install step is reused from cache.

  12. Question 12. Which workload type fits a stateless web front end that should keep three identical replicas running?

    1. DaemonSet
    2. Job
    3. StatefulSet
    4. Deployment
    Show answer

    Answer: D. Deployment

    A Deployment manages interchangeable replicas through ReplicaSets and supports rolling updates and rollbacks.

  13. Question 13. A CronJob's previous run is still going when the next scheduled time arrives. Which setting skips the new run?

    1. concurrencyPolicy: Replace
    2. concurrencyPolicy: Forbid
    3. suspend: true
    4. startingDeadlineSeconds: 0
    Show answer

    Answer: B. concurrencyPolicy: Forbid

    Forbid skips the new run while one is active. Replace stops the running Job and starts a new one. Allow, the default, runs them side by side.

  14. Question 14. What does concurrencyPolicy: Replace do on a CronJob?

    1. Runs the new Job alongside the old one
    2. Skips the new run until the old one ends
    3. Stops the running Job and starts the new one
    4. Deletes the history of all earlier Jobs
    Show answer

    Answer: C. Stops the running Job and starts the new one

    Replace cancels the still-running Job and replaces it with the newly scheduled one.

  15. Question 15. A Job must succeed 10 times, with at most 3 Pods running at once. Which fields set this?

    1. replicas: 10 and maxSurge: 3
    2. parallelism: 10 and completions: 3
    3. backoffLimit: 10 and activeDeadlineSeconds: 3
    4. completions: 10 and parallelism: 3
    Show answer

    Answer: D. completions: 10 and parallelism: 3

    completions is the number of successful Pods required; parallelism caps how many run at the same time.

  16. Question 16. Which restartPolicy values are allowed in a Job's Pod template?

    1. Always only
    2. OnFailure or Never
    3. Always or OnFailure
    4. Any value, including Always
    Show answer

    Answer: B. OnFailure or Never

    A Job's Pods must eventually finish, so Always is rejected. OnFailure restarts the container in place; Never creates a new Pod on failure.

  17. Question 17. A Job's Pods keep failing. Which field caps the retries before the Job is marked as failed?

    1. activeDeadlineSeconds
    2. completions
    3. backoffLimit
    4. ttlSecondsAfterFinished
    Show answer

    Answer: C. backoffLimit

    backoffLimit (default 6) is the number of retries, with exponential back-off between them, before the Job fails.

  18. Question 18. Which Job field stops the Job, and terminates its running Pods, once it has run for a set time?

    1. activeDeadlineSeconds
    2. backoffLimit
    3. terminationGracePeriodSeconds
    4. startingDeadlineSeconds
    Show answer

    Answer: A. activeDeadlineSeconds

    activeDeadlineSeconds applies to the whole Job and takes precedence over backoffLimit. startingDeadlineSeconds is a CronJob field about late starts.

  19. Question 19. Which field deletes a finished Job and its Pods automatically after a delay?

    1. backoffLimit
    2. ttlSecondsAfterFinished
    3. successfulJobsHistoryLimit
    4. activeDeadlineSeconds
    Show answer

    Answer: B. ttlSecondsAfterFinished

    The TTL-after-finished controller deletes the Job (and its dependent Pods) that many seconds after it completes or fails.

  20. Question 20. Which command runs a CronJob's Job immediately, for testing, without waiting for the schedule?

    1. kubectl run test-run --cronjob=report
    2. kubectl rollout restart cronjob/report
    3. kubectl create job test-run --from=cronjob/report
    4. kubectl patch cronjob report --now
    Show answer

    Answer: C. kubectl create job test-run --from=cronjob/report

    kubectl create job --from=cronjob/<name> creates a Job from the CronJob's jobTemplate.

  21. Question 21. A CronJob has schedule: "*/15 * * * *". When does it run?

    1. At 15 minutes past each hour
    2. Every day at 3:00 p.m.
    3. On the 15th day of every month
    4. Every 15 minutes
    Show answer

    Answer: D. Every 15 minutes

    The first field is minutes, and */15 means every 15 minutes (0, 15, 30, 45). "15 * * * *" would mean 15 minutes past each hour.

  22. Question 22. Which CronJob field sets the time zone its schedule is interpreted in?

    1. spec.jobTemplate.timezone
    2. spec.timeZone, such as Europe/London
    3. An environment variable TZ in the Pod
    4. The --tz flag on the controller manager
    Show answer

    Answer: B. spec.timeZone, such as Europe/London

    spec.timeZone takes an IANA time zone name. Without it, the schedule uses the kube-controller-manager's local time zone.

  23. Question 23. What does an indexed Job (completionMode: Indexed) give each of its Pods?

    1. A stable network identity like a StatefulSet
    2. Its own PersistentVolumeClaim
    3. A completion index in the JOB_COMPLETION_INDEX variable
    4. A separate copy of the Job's ConfigMap
    Show answer

    Answer: C. A completion index in the JOB_COMPLETION_INDEX variable

    Each Pod gets an index from 0 to completions-1, in an annotation and the JOB_COMPLETION_INDEX environment variable, so it can pick its share of the work.

  24. Question 24. Which containers run to completion before a Pod's app containers start?

    1. Sidecar containers
    2. Ephemeral containers
    3. Init containers
    4. Adapter containers
    Show answer

    Answer: C. Init containers

    Init containers run before the app containers, for example to wait for a dependency or prepare files on a shared volume.

  25. Question 25. A Pod has two init containers. How do they run?

    1. In parallel, before the app container
    2. One at a time, in order; each must succeed first
    3. In parallel with the app container
    4. In random order until one of them succeeds
    Show answer

    Answer: B. One at a time, in order; each must succeed first

    Init containers run sequentially. If one fails, the kubelet retries it according to the Pod's restartPolicy, and later ones don't start.

  26. Question 26. Which pattern adds a helper container that ships the app's log files to a central logging system?

    1. Sidecar
    2. Init container
    3. Ambassador
    4. Ephemeral container
    Show answer

    Answer: A. Sidecar

    A sidecar runs alongside the main container for the Pod's lifetime, here reading logs from a shared volume and forwarding them.

  27. Question 27. How do you declare a native sidecar container that starts before the app containers and keeps running?

    1. A container with lifecycle: sidecar
    2. An init container with restartPolicy: Always
    3. An ephemeral container added at creation
    4. A second container with no startup probe
    Show answer

    Answer: B. An init container with restartPolicy: Always

    An init container with restartPolicy: Always starts before the app containers, keeps running alongside them, and is stopped after them.

  28. Question 28. Which pattern uses a helper container to convert the app's metrics into the format a monitoring system expects?

    1. Ambassador
    2. Init container
    3. Adapter
    4. Static Pod
    Show answer

    Answer: C. Adapter

    An adapter standardizes or transforms the main container's output for outside consumers.

  29. Question 29. Which pattern uses a local proxy container, so the app connects to localhost while the proxy handles the remote database?

    1. Adapter
    2. Ambassador
    3. Init container
    4. DaemonSet
    Show answer

    Answer: B. Ambassador

    An ambassador proxies outbound connections, hiding details such as sharding, TLS, or service discovery from the app.

  30. Question 30. What is the simplest way for two containers in the same Pod to share files?

    1. Use a hostPath on each container's node
    2. Expose a Service between the two containers
    3. Mount the same emptyDir volume in both
    4. Copy files with kubectl cp at startup
    Show answer

    Answer: C. Mount the same emptyDir volume in both

    Volumes are defined at Pod level and can be mounted into any of its containers. An emptyDir lives as long as the Pod.

  31. Question 31. Two containers in one Pod need to talk over the network. Which address does one use to reach the other?

    1. localhost and the other container's port
    2. The other container's own Pod IP
    3. The Service name plus the container name
    4. The node's IP and a NodePort
    Show answer

    Answer: A. localhost and the other container's port

    Containers in a Pod share one network namespace and IP, so they reach each other on localhost. They can't both listen on the same port.

  32. Question 32. Which emptyDir setting keeps the volume in memory instead of on the node's disk?

    1. type: tmpfs
    2. storage: ram
    3. sizeLimit: 0
    4. medium: Memory
    Show answer

    Answer: D. medium: Memory

    medium: Memory backs the emptyDir with tmpfs. Its contents count against the container's memory limit.

  33. Question 33. An app needs its own Pod name as an environment variable. What provides it?

    1. A ConfigMap created by the kubelet
    2. The downward API, with fieldRef metadata.name
    3. The hostname field in the Service spec
    4. An annotation copied by the scheduler
    Show answer

    Answer: B. The downward API, with fieldRef metadata.name

    The downward API exposes Pod fields (name, namespace, IP, labels) and resource values as environment variables or files.

  34. Question 34. Which volume type combines data from a ConfigMap, a Secret, and the downward API into one mounted directory?

    1. emptyDir
    2. projected
    3. subPath
    4. csi
    Show answer

    Answer: B. projected

    A projected volume maps several sources (configMap, secret, downwardAPI, serviceAccountToken) into one directory.

  35. Question 35. A ConfigMap key is mounted into a container using subPath. What happens when the ConfigMap changes?

    1. The mounted file is never updated
    2. The file updates within about a minute
    3. The Pod restarts automatically
    4. The Pod is evicted and rescheduled
    Show answer

    Answer: A. The mounted file is never updated

    Files mounted with subPath don't receive ConfigMap or Secret updates. Restart the Pod, or mount the whole volume without subPath.

  36. Question 36. Which volume gives a Pod scratch storage provisioned through a StorageClass and deleted along with the Pod?

    1. A hostPath volume
    2. A static PersistentVolume
    3. A projected volume
    4. A generic ephemeral volume
    Show answer

    Answer: D. A generic ephemeral volume

    A generic ephemeral volume embeds a PVC template in the Pod. The PVC is created with the Pod and removed when the Pod is deleted.

  37. Question 37. Which volumeMounts field mounts a volume so the container can't write to it?

    1. mode: ro
    2. readOnly: true
    3. writable: false
    4. accessModes: ReadOnlyMany
    Show answer

    Answer: B. readOnly: true

    readOnly: true on the volumeMount makes the mount read-only. accessModes belongs to PVs and PVCs, not mounts.

  38. Question 38. A Deployment with one shared ReadWriteOnce PVC is scaled from 1 to 3 replicas. Why can this fail?

    1. Kubernetes deletes the PVC when replicas change
    2. Each replica gets an empty copy of the volume
    3. Only Pods on the node that attached it can use the volume
    4. PVCs can't be referenced by Deployments
    Show answer

    Answer: C. Only Pods on the node that attached it can use the volume

    ReadWriteOnce allows one node to mount the volume. Replicas scheduled to other nodes get stuck in ContainerCreating with attach errors.

  39. Question 39. Which container field sets the working directory, overriding the image's WORKDIR?

    1. cwd
    2. homeDir
    3. mountPath
    4. workingDir
    Show answer

    Answer: D. workingDir

    workingDir sets the directory the container's process starts in.

  40. Question 40. Which command creates a Pod named box that runs busybox with the command sleep 3600?

    1. kubectl create pod box --image=busybox sleep 3600
    2. kubectl run box --image=busybox -- sleep 3600
    3. kubectl exec box --image=busybox -- sleep 3600
    4. kubectl apply box --image=busybox --args=3600
    Show answer

    Answer: B. kubectl run box --image=busybox -- sleep 3600

    Everything after -- is passed to the container as args (with --command, as the command). kubectl create has no pod subcommand.

CKAD, Certified Kubernetes Application Developer, and Kubernetes are trademarks of The Linux Foundation. These questions are original study material, not questions from the real exam.