我有一个python(with poetry)应用程序,我通过这个文件进行了dockerized:
FROM python:3.10
WORKDIR /app
RUN apt-get update && apt-get install -y curl
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH=$PATH:/root/.local/bin
COPY . .
# COPY pyproject.toml poetry.lock ./
RUN poetry install
ENTRYPOINT ["poetry", "run", "python", "-m", "my-app"]
我的应用程序通过诗歌运行使用以下命令:poetry run python -m my_app file
,其中'file'被替换为应用程序所需文件的路径。
我运行docker build -t my-app .
和这个工作。
当我尝试运行docker时:docker run --rm -it my-app path/to/file.ext
返回以下错误:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/app/my_app/__main__.py", line 68, in <module>
main()
File "/app/my_app/__main__.py", line 44, in main
app.aquire_application()
File "/app/my_app/app.py", line 37, in aquire_application
self.config.load_config_from_file(self.config_path)
File "/app/my_app/frontend/config.py", line 19, in load_config_from_file
with open(config, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/app/files/temp/config.yaml'
我该如何解决?(Ubuntu)谢谢
1条答案
按热度按时间kh212irz1#
您可以通过使用交互式bash脚本运行Docker容器来调试它
一旦你在容器里你就可以
1.检查
COPY
命令复制到容器中的文件的文件路径1.确认Poetry已正确安装在容器中
注意:如果Dockerfile没有
ENTRYPOINT
,语法将更像docker run -it my-app /bin/bash