I am creating a docker image of a python project like this:
FROM python:3.7
RUN git clone https://github.com/a/abc.git
WORKDIR abc
RUN pip install -r requirements.txt
CMD [ "python3", "./cascade.py --setup" ]
CMD [ "python3", "./cascade.py" ]
when the first CMD runs that is CMD [ "python3", "./cascade.py --setup" ]
, it needs some arguments to set by the user that is as follows:
My Question
How do I set the default values that are just pressing enter or ask the user to input the values when I run sudo docker build . -t pythonimg
as without this confirmation, the second command will not work and will throw errors.
2
Answers
Update: You can create a file with your configuration values one per line:
You can then save this file and copy it in your build in the
Dockerfile
:You can then feed this to your program as:
This should work.
Additionally, you can create build arguments for your
docker build
using theARG
instruction. (Read more here).This way, it can run like:
You will then use these arguments in your
docker build
command with--build-arg
switch as follows:This you can provide through your automated system easily and pass onto your image build.
you can pipe in yes for the command. This seems to be the preferred way to do this