我有一个读取配置文件的应用程序:
config.read('/data123/config/conf.ini')
conf.ini
中存在文件/data123/config/
当我从命令行运行应用程序时,应用程序可以成功找到conf.ini
我为我的应用程序创建了一个泊坞窗,当我运行泊坞窗时,该应用程序找不到该文件。
我的dockerfile:
FROM ubuntu:latest
RUN apt update -y
RUN apt install -y python3-pip
COPY . /app
WORKDIR /app
RUN pip3 install -r requirements.txt
ENTRYPOINT ["python3"]
CMD ["main.py"]
这是为什么?
使用容器时如何从应用程序读取配置文件?
使用此命令运行Docker:
sudo docker run -it -v path_to_file_you_want_to_work_with:/app/data123/config/ your_docker_name
并且容器将运行并在运行时加载您提供的配置文件