【问题标题】:Dockerfile showing error "failed to compute cache key: "/Pipfile.lock" not found"显示错误的 Dockerfile \"无法计算缓存键:\"/Pipfile.lock\" not found\"
【发布时间】:2023-02-12 17:06:55
【问题描述】:

文件:

FROM python:3.8-slim-buster
RUN apt-get update && \
 apt-get -y upgrade && \
 apt-get install -y --no-install-recommends make && \
 apt-get clean && \
 rm -rf /var/lib/apt/lists/* && \
 pip install --no-cache-dir --upgrade pip && \
 pip install --no-cache-dir pipenv

WORKDIR /sphinxtechnicalwriting

COPY Pipfile Pipfile.lock /sphinxtechnicalwriting/

RUN pipenv install --system --deploy

错误显示:

=> CANCELED [2/5] RUN apt-get update &&     apt-get -y upgrade &&     apt-get install -y --no-install-recommends make &&     apt-get clean &&       0.6s
 => CACHED [3/5] WORKDIR /sphinxtechnicalwriting                                                                                                     0.0s
 => ERROR [4/5] COPY Pipfile Pipfile.lock /sphinxtechnicalwriting/                                                                                   0.0s
------
 > [4/5] COPY Pipfile Pipfile.lock /sphinxtechnicalwriting/:
------
failed to compute cache key: "/Pipfile.lock" not found: not found

尝试清除 pipfile 缓存,但现在它在第一次运行命令中也取消了

【问题讨论】:

  • Pipfile.lock 在您的主机系统上是否与 Pipfile(可能还有 Dockerfile)在同一目录中?
  • 是的,通过单独安装 pipenv lock 解决了这个错误。但其他错误仍未解决

标签: docker dockerfile pipenv


【解决方案1】:

当你构建你的 docker 镜像时

在步骤

COPY Pipfile Pipfile.lock /sphinxtechnicalwriting/

文件 PipfilePipfile.lock 将从您启动 docker build ... (或您启动构建的其他命令)的同一文件夹复制到 docker 映像。

错误说源文件夹中没有这样的文件。

【讨论】:

  • 现在错误:[2/5] RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends make && apt-get clean && rm -rf /var/lib/apt /lists/* && pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir pipenv: #6 23.25 包制作不可用,但被另一个包引用。 #6 23.25 这可能意味着该软件包丢失、已被废弃,或者 #6 23.25 只能从其他来源获得 #6 23.25 E: 软件包“make”没有安装候选项 ------
  • 执行者运行失败apt/lists/* && pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir pipenv]: 退出代码:100
  • @TaruArora:如果您有其他需要帮助的错误,请提出一个新问题。
【解决方案2】:

我今天遇到了同样的错误,解决方法是删除'Pipfile.lock'从我的'.dockerignore'文件,这就是 Docker 找不到 Pipfile 的原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-18
    • 2020-02-04
    • 2021-07-27
    • 2015-05-31
    • 2021-10-05
    • 1970-01-01
    相关资源
    最近更新 更多