简体   繁体   English

在 docker 中构建容器时“没有此类文件或目录”。 似乎无法编辑到正确的路径

[英]"No such file or directory" when building containter in docker. Can't seem to edit to the right path

For building my container.用于构建我的容器。 I'm using python scripts to build and fill a mysql database.我正在使用 python 脚本来构建和填充 mysql 数据库。 But when running the docker compose up.但是在运行 docker 时组成。 The python exits and I get 'python3: can't open file '/root/python_scripts/01_create_db.py': [Errno 2] No such file or directory' python 退出,我得到'python3:无法打开文件'/root/python_scripts/01_create_db.py':[Errno 2]没有这样的文件或目录'

It keeps refering to '/root/python_scripts/01_create_db.py'.它一直引用'/root/python_scripts/01_create_db.py'。

I don't know where docker get that info from.我不知道 docker 从哪里得到这些信息。

This is the dockerfile:这是 dockerfile:

FROM python:latest

RUN mkdir /usr/src/app
WORKDIR /usr/src/app
 
RUN pip install mysqlclient
RUN pip install mysql-connector-python

COPY python.sh ./
RUN chmod a+x python.sh
COPY . .

CMD [ "./python.sh"]

This is the python.sh:这是 python.sh:

#!/bin/bash

exec python3 "01_create_db.py"
exec python3 "02_Quant_report_automated_insert.py"
exec python3 "03_Reagent_report_automated_insert.py"
exec python3 "04_Run_parameters_automated_insert.py"
exec python3 "05_Sequencing_report_automated_insert.py"

and this is the docker compose part with the mysql and python:这是 docker 与 mysql 和 python 组成部分:

mysql:
        image: mariadb:latest
        environment:
            MYSQL_ROOT_PASSWORD: 'nipt@qc'
            MYSQL_USER: 'MolBio'
            MYSQL_PASSWORD: 'nipt@qc'
            MYSQL_DATABASE: 'nipt'
        volumes:
          - mysqldata:/var/lib/mysql
        ports:
            - 3307:3306
    python:
        build: 
            context: .
            dockerfile: Python.Dockerfile
        depends_on:
            - mysql
        volumes:
            - .:/usr/src/app

Any idea on how to look to fix this issue would be appreciated.任何有关如何解决此问题的想法将不胜感激。 Thanks in advance.提前致谢。

I figured it out.我想到了。 I inspected it via VS to get a detailed.json file.我通过VS对其进行了检查以获取详细的.json 文件。 noticed that workingdir was /root/python_scripts.注意到workingdir 是/root/python_scripts。

So I figured out that it was the image itself that still held an older path from previous tries.所以我发现图像本身仍然保留了之前尝试的旧路径。 So I deleted the image and remade it.所以我删除了图像并重新制作了它。 Now it refers to the new workdir in the dockerfile.现在它指的是 dockerfile 中的新工作目录。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 码头工人。 没有这样的文件或目录 - Docker. No such file or directory Docker中的Django。 看不到日志 - Django in docker. Can't see logs 构建 Docker 映像时“没有此类文件或目录” - “No such file or directory” when building Docker image 如何解决 docker 的 PyCharm 错误“无法打开文件 'path/to/file.py': [Errno 2] No such file or directory”? - How to solve PyCharm error with docker "can't open file 'path/to/file.py': [Errno 2] No such file or directory"? python: 无法打开文件 'manage.py': [Errno 2] 编写时没有这样的文件或目录 docker - python: can't open file 'manage.py': [Errno 2] No such file or directory when compose docker docker 中的 Gitlab CI。 在阶段开始之前禁用清理目录 - Gitlab CI in docker. Disable cleaning directory before stage starts 递归目录列表/分析功能似乎未正确递归 - Recursive directory list/analyze function doesn't seem to recurse right Spacy:找不到模型“en_core_web_sm”。 它似乎不是 Python 包或数据目录的有效路径 - Spacy: Can't find model 'en_core_web_sm'. It doesn't seem to be a Python package or a valid path to a data directory OSError: [E050] 找不到 model 'en'。 它似乎不是快捷链接、Python package 或数据目录的有效路径 - OSError: [E050] Can't find model 'en'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory 找不到 model 'en_core_web_lg'。 它似乎不是快捷链接、Python package 或数据目录的有效路径 - Can't find model 'en_core_web_lg'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM