use Helm charts for the deployments
This is easy: Kubernetes command:
overrides Docker ENTRYPOINT
(and Kubernetes args:
matches Docker CMD
). So your Deployment spec can just say
command:
- python3
- main_script.py
- {{ .Values.environment }}
Usually, though, you shouldn't need to override ENTRYPOINT
, especially in a docker run
context. An ENTRYPOINT
isn't required, and it's very easy to override CMD
at the end of the docker run
line. So if you change your Dockerfile to say
CMD python3 some_other_script.py
# with no ENTRYPOINT
then you can
docker run my-image \
python3 main_script.py DEV
If that's not an option, then you need to be aware of the limitation that docker run --entrypoint
only takes a single shell word. That means the first word of your command goes with --entrypoint
and is a Docker option (before the image name), and the rest is interpreted as a command (after the image name).
docker run \
--entrypoint python3 \
my-image \
main_script.py DEV