3

I want to pass argument to python file app.py while running its docker image using command :

docker run -d -p 5000:5000 python_app https://github.com/abc/repo

where python_app is image of my application and https://github.com/abc/repo is the argument which I want to pass. But when I run docker image using above command my container exits with error :No such directory or file found

This is my Dockerfile

FROM python:2.7.13
MAINTAINER xyz "[email protected]"
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["app.py","https://github.com/abc/repo"]

I think my param2 in CMD is treated an argument for docker image rather than argument for python application.

1 Answer 1

1

td;lr use ENTRYPOINT ["python", "app.py"] then you can pass parameters to the docker run

see answer here: how to pass command line arguments to a python script running in docker td

Sign up to request clarification or add additional context in comments.

5 Comments

python: can't open file 'github.com/abc/config-example': [Errno 2] No such file or directory....I am still getting this error
does the script run when passed that argument. this looks like a python error not docker
it runs perfectly fine when I make it static string instead of passing it as argument
ok, forget docker for a second, run app.py 'github.com/abc/config-example' in the shell. does that run error free?
yes , without docker also it runs perfectly fine, that's why I thought it might be docker issue or something with argument

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.