[英]"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.