Skip to content

Instantly share code, notes, and snippets.

@albscui
Created October 8, 2024 02:53
Show Gist options
  • Save albscui/ede01d1e10220a321f39200d82740b74 to your computer and use it in GitHub Desktop.
Save albscui/ede01d1e10220a321f39200d82740b74 to your computer and use it in GitHub Desktop.
K8s command vs Docker ENTRYPOINT

K8s command vs Docker ENTRYPOINT

Summary

  • command in K8s is analogous to ENTRYPOINT in Docker
  • args in K8s is analogous CMD in Docker

In Docker:

CMD has three forms

  • CMD ["executable", "param1", "param2"] exec form, preferred form
  • CMD ["param1", "param2"] defaults to ENTRYPOINT
  • CMD command param1 param2 shell form

There can only be one CMD instruction in a Dockerfile.

The main purpose of CMD is to provide defaults for an executing container

Any arguments to docker run ... overrides CMD.

ENTRYPOINT has two forms

  • ENTRYPOINT ["executable", "param1", "param2"] exec form, preferred form
  • ENTRYPOINT command param1 param2 shell form

An ENTRYPOINT allows you to configure a container that will run as an executable

Any arguments to docker run ... get appended after all elements in an exec form ENTRYPOINT, and will override all elements specified using CMD.

You can override the ENTRPOINT instruction using the docker run --entrypoint flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment