I have a python file called perf_alarm_checker.py
, this python file requires two command line arguments: python perf_alarm_checker.py -t something -d something
, the Dockerfile looks like this:
# Base image
FROM some base image
ADD perf_alarm_checker.py /perf-test/
CMD python perf_alarm_checker.py
How to pass the two command line arguments, -t
and -d
to docker run
? I tried docker run -w /perf-test alarm-checker -t something -d something
but doesn't work.
Use an ENTRYPOINT instead of CMD and then you can use command line options in the docker run like in your example.
ENTRYPOINT ["python", "perf_alarm_checker.py"]
You cannot use
-t
and-d
as you intend, as those are options fordocker run
.-t
starts a terminal.-d
starts the docker container as a daemon.For setting environment variables in your Dockerfile use the
ENV
command.See the Dockerfile reference.
Another option is to pass environment variables through
docker run
:See the docker run reference.
Those environment variables can be accessed from the
CMD
.