3

I want to make an external config file via volume and pass it like:

docker run MyImage -v /home/path/my_config.conf:folder2/(is that right btw?)

But have no idea how to link this volume to the argument for the main.py...

My DocekrFile:

FROM python:3.6-jessie
MAINTAINER Vladislav Ladenkov

WORKDIR folder1/folder2

COPY folder2/requirements.txt .

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

COPY folder2/*.py ./

?? how to link volume ??

ENTRYPOINT ["python3", "main.py", "@??volume??"]
Ladenkov Vladislav
  • 1,156
  • 1
  • 18
  • 40

1 Answers1

5

You want to use a folder-name to map the volume: docker run MyImage -v /home/path/:/folder1/folder2/ So now /home/path folder on the host machine is mounted to /folder1/folder2 inside the container.

Then just pass the path of the conf file as seen within the container to the cmd. ENTRYPOINT ["python3", "main.py", "/folder1/folder2/myconf.conf"]

sxm1972
  • 683
  • 7
  • 14
  • hmm, can i do the same thing, but for the file? `/home/path/myconf.conf:/folder1/folder2/myconf.conf` – Ladenkov Vladislav Feb 12 '18 at 13:48
  • According to this post you can map a file. i have not tried it though. https://stackoverflow.com/questions/42248198/how-to-mount-a-single-file-in-a-volume – sxm1972 Feb 12 '18 at 15:00