当前位置: 代码迷 >> python >> Docker映射一个外部配置文件
  详细解决方案

Docker映射一个外部配置文件

热度:77   发布时间:2023-07-16 11:03:35.0

我想通过卷制作一个外部配置文件,并像这样传递它:

docker run MyImage -v /home/path/my_config.conf:folder2/ (顺便说一句吗?)

但是不知道如何将此卷链接到main.py的参数上...

我的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??"]

您要使用文件夹名称来映射卷: docker run MyImage -v /home/path/:/folder1/folder2/因此,现在主机上的/ home / path文件夹已安装到容器内的/ folder1 / folder2 。

然后只需将conf文件的路径(如在容器中看到的)传递到cmd。 ENTRYPOINT ["python3", "main.py", "/folder1/folder2/myconf.conf"]

  相关解决方案