1

I have a dockerfile finishing with an entrypoint:

ENTRYPOINT ["/bin/bash" , "-c", "source /app/env.sh && printenv && python3 /app/script.py"]

And a yaml k8s CronJob:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: my_healthcheck
  namespace: default
  labels:
    app: my_healthcheck
spec:
  schedule: "30 8 * * 1-5"
  jobTemplate:
    spec:
      backoffLimit: 5
      template:
        spec:
          containers:
            - name: pythonscript
              image: xxx/pythonscript:latest
          imagePullPolicy: IfNotPresent
          command: [ <what do i put here> ]
          restartPolicy: OnFailure

Inside "command", what command i need to put, to run the container ? thanks

YoussHark
  • 558
  • 1
  • 9
  • 26
  • 2
    What command do you need to run (if any)? If you're fine with just running what's in `ENTRYPOINT` just omit `command` entirely. – zerkms Nov 18 '20 at 22:20
  • zerkms is right, if you don't need to overwrite what is already in your `ENTRYPOINT`, you don't need `command` at all. Are you facing any issues when running it this way ? – mario Nov 19 '20 at 11:20
  • 1
    @zerkms and mario. thanks for the replies. Oh ok ! i thought i had to put something in "command" like it was mandatory field. I don't need to override the entrypoint so i will just get rid of it ! thank you both – YoussHark Nov 19 '20 at 14:40

1 Answers1

3

The image ENTRYPOINT handles everything, so the command doesn't need to supplied.

If you do provide a command, it will override the ENTRYPOINT.

    command: [ '/bin/bash', '-c', 'echo "not running python"' ]

You can supply args if you want to append arguments to the command/ENTRYPOINT.

See the difference between the Kubernetes/Docker terms.

Matt
  • 68,711
  • 7
  • 155
  • 158
  • 3
    (But if you use a complex `ENTRYPOINT`/`command:` with `sh -c`, the `CMD`/`args:` are mostly entirely ignored.) – David Maze Nov 19 '20 at 01:57
  • 1
    Good point. They are there, just hard to get at. `/bin/bash -c 'echo "[$0] [$1]"' some thing` – Matt Nov 19 '20 at 02:28