CMD

The Dockerfile instruction that sets the default command a container runs when you do not give one.

In more detail

Anything you type after the image name in docker run replaces CMD. When an ENTRYPOINT is set, CMD becomes its default arguments instead. Write it in exec form, a JSON array of the program and its arguments, so the program receives stop signals directly. Only the last CMD in a Dockerfile counts.

Examples

CMD ["python", "app.py"]
CMD ["node", "dist/index.js"] after USER node

Related terms

Taught in

References

Certification courses