Search code examples
dockerkuberneteskubectl

How to determine the ENTRYPOINT of an image with kubectl or inside a container?


I can read out the images metadata with docker inspect.

But

  1. in an kubernetes environment - is there a way to get the defined entrypoint of an image with kubectl commands?
  2. is it possible to find the entrypoint in a shell/bash console of the running container?

I looked around with kubectl commands, describing deployments, pods, but if the "command" and/or "args" value was not overridden by a kubernetes yaml, i was not able to find the dockerfiles entrypoint.


Solution

  • I don't think this information is reliably available in any way other than inspecting the Dockerfile or docker inspecting a built image.

    Kubernetes will not update a Pod's status or anything else in the Kubernetes API with metadata about the image, except for including the SHA-256 hash of the image that's actually being used. There's no way to get this information back via kubectl; Kubernetes simply doesn't have it.

    It's probably not available in a debugging shell either (if it's even possible to get one; some images don't include a shell for size and security reasons). If you can get a shell, and if you have core tools available, then ps(1) could show you the command line for the process with process ID 1; but if the image has an entrypoint wrapper script that ends with exec "$@", that will replace the entrypoint process with the CMD process. If you can get that command line, it will include the entrypoint and command strings combined together.

    The most common case of actually needing to know this is to want to further wrap an entrypoint wrapper with custom setup, then exec the original entrypoint. You do need to do something like docker inspect the image to find out what the entrypoint value was; it is not going to be visible anywhere in Kubernetes deployment YAML.