Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker map an external config file

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??"]
like image 792
Ladenkov Vladislav Avatar asked May 16 '26 18:05

Ladenkov Vladislav


1 Answers

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"]

like image 134
sxm1972 Avatar answered May 18 '26 07:05

sxm1972



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!