Reputation: 110
I building a CLI python application that takes a CSV file as argument input and various options
Example:
rexona [-h] [-v | -q] [-o] filepath
My question is how to dockerize it in a way that when I run my docker file I can run the above command and pass in the specified arguments?
My current docker file
FROM python:3
WORKDIR .
COPY . .
CMD ["python","app.py"]
Should I also install an os image such as ubuntu, so that I can run cmd commands or is there a way to that in docker?
Apologies, I'm still new to docker. Thanks
Upvotes: 3
Views: 3600
Reputation: 468
I also run into similar senario i solved it using Entry point
ENTRYPOINT [ "python", "script.py" ]
run script
docker run arg1 arg2 arg3...
And then in Python Program
import sys
print(sys.argv)
Upvotes: 2
Reputation: 994
You need to add entry point for eg:
# Base image of the docker container
FROM python:3
# Copy the contents of the repo into the /app folder inside the container
COPY . /app
# Update the current working directory to the /app folder
WORKDIR /app
# Add your CLI's installation setups here using the RUN command
# If you have any pip requirements you can do that here
# RUN pip install --user -r requirements.txt
# Provdide a path to your cli apps executable
ENTRYPOINT [ "python", "script.py" ]
Upvotes: 4