Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pass command line arguments to a python script running in docker

Tags:

docker

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.

like image 574
msn Avatar asked Mar 03 '16 08:03

msn


People also ask

How do I run a command in a running docker container?

Running Commands in an Alternate Directory in a Docker Container. To run a command in a certain directory of your container, use the --workdir flag to specify the directory: docker exec --workdir /tmp container-name pwd.


1 Answers

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"]

like image 140
Michael Avatar answered Oct 04 '22 04:10

Michael