gpt4 book ai didi

docker - 我的Dockerfile遇到问题并设置了正确的工作目录

转载 作者:行者123 更新时间:2023-12-02 18:34:39 25 4
gpt4 key购买 nike

这是我的第一个Dockerfile,这是我到目前为止所拥有的。

FROM python:3.6-stretch


# install build utilities
RUN apt-get update && \
apt-get install -y gcc make apt-transport-https ca-certificates build-essential

# check our python environment
RUN python3 --version
RUN pip3 --version

# set the working directory for containers
WORKDIR /usr/src/toxic-content-monitoring

# Installing python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy all the files from the project’s root to the working directory
COPY src/ /src/
RUN ls -la /src/*

# Running Python Application
CMD ["python3", "/src/main.py"]

但是当我尝试运行docker镜像时,找不到数据文件夹内的文件。
这是我的项目结构的图片。
enter image description here

将其更改为建议的内容,仍然出现错误。
FROM python:3.6-stretch

# install build utilities
RUN apt-get update && \
apt-get install -y gcc make apt-transport-https ca-certificates build-essential

# check our python environment
RUN python3 --version
RUN pip3 --version

# set the working directory for containers
WORKDIR /usr/src/toxic-content-monitoring

# Installing python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy all the files from the project’s root to the working directory
COPY src/ /src/
COPY data /data/
RUN ls -la /src/*

# Running Python Application
CMD ["python3", "/src/main.py"]

这是错误消息。
docker run toxic-content-monitoring:0.1
wiki.en.vec: 6.60GB [10:05, 10.9MB/s]
0%| | 0/2519371 [00:00<?, ?it/s]Skipping token 2519370 with 1-dimensional vector ['300']; likely a header
100%|██████████| 2519371/2519371 [08:36<00:00, 4878.67it/s]
Traceback (most recent call last):
File "/src/main.py", line 11, in <module>
from preprocessor import normalize_comment, clean_text
File "/src/preprocessor.py", line 42, in <module>
word_file = open(link, "r")
FileNotFoundError: [Errno 2] No such file or directory: 'data/identity_hateWordFile.txt'

最佳答案

我相信您的Dockerfile中缺少COPY data/ /data/命令。您仅在复制src文件夹,而不在复制数据。请在Dockerfile中的COPY src / / src /行之后添加COPY data /data/,然后尝试一下。

关于docker - 我的Dockerfile遇到问题并设置了正确的工作目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61787013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com