Courseiva

CKAD Application Design and Build Practice Question

A developer is writing a Dockerfile and wants to ensure that the container runs a Python script named 'app.py' as its main process. Which instruction should be used?

⚠ Common exam trap

Many candidates confuse CMD with ENTRYPOINT, thinking CMD always runs the main process, but CMD can be overridden and is often used for default arguments, while ENTRYPOINT is designed to be the immutable executable.

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

✓

ENTRYPOINT ["python", "app.py"]

ENTRYPOINT defines the executable that runs as the main process in the container. When combined with CMD (or used alone in exec form), it ensures that 'python app.py' is the primary process with PID 1, which is essential for proper signal handling and container lifecycle management.

Answer analysis

Option-by-option breakdown

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

  • ✗

    EXPOSE 8080

    Why it's wrong here

    EXPOSE only declares port 8080 as metadata in the image configuration; it does not start any process, bind the port, or make the container listen for connections. To actually make the port accessible from the host, you must publish it with the -p or -P flag when running the container, and the application itself must be listening on that port. EXPOSE is purely informational, useful for documentation and for orchestrators that infer which ports to map, but it has no runtime effect.

  • ✗

    CMD ["python", "app.py"]

    Why it's wrong here

    CMD provides the default command that runs when the container starts, but it is intentionally overridable by passing arguments to docker run, so it cannot guarantee that python app.py will execute. If an ENTRYPOINT is also present, CMD supplies default arguments to that ENTRYPOINT rather than running as the main command, which further changes its behavior. Because users can easily replace the default command with any other command at runtime, CMD alone is not a reliable way to ensure the application always starts.

  • ✓

    ENTRYPOINT ["python", "app.py"]

    Why this is correct

    ENTRYPOINT sets the container's primary executable and is the instruction that ensures python app.py runs whenever the container starts, because the command is baked into the image's configuration. Any arguments supplied with docker run are appended to the ENTRYPOINT array rather than replacing it, so the default process remains python app.py. Only the explicit --entrypoint flag can override it, making ENTRYPOINT the correct choice when the application must always be the container's main process.

  • ✗

    RUN ["python", "app.py"]

    Why it's wrong here

    RUN executes a command during the image build phase, creating a new layer and committing the result, so it has no impact on what process runs at container startup. Placing python app.py in a RUN instruction would cause the application to launch during docker build, potentially failing if the app or its dependencies are not yet present, and the build would not produce a runnable service. It is a build-time instruction meant for installing packages and preparing the image, not for defining the container's runtime command, which must come from CMD or ENTRYPOINT.

About these practice questions

Courseiva writes every CKAD question from scratch — 826 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CKAD practice question is part of Courseiva's free CNCF 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 CKAD exam.