exec form

Writing RUN, CMD or ENTRYPOINT as a JSON list such as ["python", "app.py"], so the program runs directly without a shell.

In more detail

In shell form, CMD python app.py actually runs /bin/sh -c "python app.py": the shell becomes PID 1 and may not pass SIGTERM on, so docker stop waits and then kills. Exec form runs your program as PID 1 directly. Exec form needs double quotes because it is JSON; shell form is still handy for RUN steps that use pipes or variables.

Examples

CMD ["python", "app.py"]   # exec form
CMD python app.py          # shell form

Related terms

Taught in

References

Certification courses