liveBook · Manning

Shell form

As explained in Kubernetes in Action, Second Edition

The shell form is Dockerfile syntax that runs an ENTRYPOINT or CMD instruction through a shell.

The shell form runs a Dockerfile’s ENTRYPOINT or CMD through a shell. For example, `ENTRYPOINT /myexecutable 1st-arg 2nd-arg` starts a shell as the container’s root process, which then starts the executable. section 6.3.2

This process arrangement affects termination. The shell receives SIGTERM but does not pass it to the child application, so the application may not shut down gracefully. The exec form calls the executable directly and makes it the container’s root process. section 6.3.2

Contrasting Dockerfile forms

Shell form: `CMD /myexecutable 1st-arg 2nd-arg`. Exec form: `ENTRYPOINT ["/myexecutable", "1st-arg", "2nd-arg"]`. Prefer the exec form when the application must receive termination signals directly. section 6.3.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Defines shell and exec syntax, explains their process relationship, and identifies signal forwarding as the operational consequence.
Examples
Contrasts shell-form and exec-form ENTRYPOINT examples while discussing an application’s termination behavior.
What it assumes
Assumes familiarity with Dockerfile ENTRYPOINT and CMD while contrasting their shell and exec forms.
What you can do after
Diagnose/debug missing SIGTERM delivery by inspecting ENTRYPOINT or CMD syntax and selecting exec form when appropriate.
How it connects
Connects ENTRYPOINT, CMD, exec form, SIGTERM, pre-stop hooks, and shell scripts.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.