Below is my Dockerfile content:
FROM python:2.7-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
RUN pip install numpy==1.12.0
CMD ["python", "t_1.py", "t_1.json"]
I want to pass this file(t_1.sjon) as argument with docker run command at runtime so that CMD ["python", "t_1.py", "RUN TIME ARGUMENT"]. I tried mounting volumes but fails as json file is independent and I want as argument.
Please help.
What you should use is ENTRYPOINT
FROM python:2.7-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
RUN pip install numpy==1.12.0
ENTRYPOINT ["python", "t_1.py"]
Now when you run the docker command
docker run -v ./t_1.json:/data/t_1.json <dockerimage> /data/t_1.json
This will make it equivalent to python t_1.py /data/t_1.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With