✦ For everyone, free.

Practical knowledge for real and everyday life

Home

4.2.7 ENTRYPOINT

A focused guide to ENTRYPOINT, connecting core concepts with practical Docker and container operations.

ENTRYPOINT is the Dockerfile instruction that defines a fixed executable a container always runs, with any arguments supplied at docker run time appended to it rather than replacing it entirely, making an image behave like a dedicated command-line tool.

Basic Usage

ENTRYPOINT specifies the program that will always execute, regardless of what additional arguments are supplied when the container starts.

ENTRYPOINT ["echo"]
docker run myimage "hello"

This always runs echo, with whatever was supplied as the run command's arguments appended — in this case, producing the output hello.

ENTRYPOINT Without CMD

Used alone, without CMD providing default arguments, every invocation must supply whatever arguments the program actually needs.

docker run myimage "custom message"
ENTRYPOINT With CMD for Default Arguments

Pairing ENTRYPOINT with CMD provides sensible default arguments, which can still be overridden without changing the fixed executable itself.

ENTRYPOINT ["echo"]
CMD ["default message"]
docker run myimage
docker run myimage "different message"
Overriding the Entrypoint Entirely

Although ENTRYPOINT is meant to be fixed, it can still be explicitly overridden at run time when genuinely necessary, such as for debugging.

docker run -it --entrypoint sh myimage

This bypasses the image's normal ENTRYPOINT entirely, starting a shell instead — useful for inspecting a container that would otherwise immediately run its fixed program.

Shell Form vs. Exec Form

Like CMD, ENTRYPOINT can be written in either shell or exec form, with the exec form generally preferred for the same signal-handling reasons.

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

ENTRYPOINT is what allows an image to function reliably as a dedicated, predictable tool — useful both for application containers that should always run the same underlying program, and for utility images explicitly designed to be invoked like a command-line tool with varying arguments.

Content in this section