Docker Community Forums

Share and learn in the Docker community.

How to pass command line arguments to my dockerized python app

(Pamparana) #1

I have a simple docker file which I am using to containerize my python app. The app actually takes file paths as command line arguments. It is my first time using Docker and I am wondering how I can achieve this:

FROM python:3.6-slim

COPY . /app

RUN apt-get update && apt-get -y install gcc g++
# Install numpy, pandas, scipy and scikit
RUN pip install --upgrade pip

RUN pip --no-cache-dir install -r requirements.txt
RUN python install

ENTRYPOINT python -m myapp.testapp

This builds the image completely fine. I can also run it using:

docker run -ti myimg

However, I cannot pass any command line arguments to it. For example, my app prints some help options with the -h option.

However, running docker as:

docker run -ti myimg -h

does not do anything. So, the command line option are not being passed.

Additionally, I was wondering what the best way to actually pass file handles from the host computer to docker.
So, for example, the application takes path to a file as an input and the file would usually reside on the host computer. Is there a way for my containerized app to be able to access that?