我想使用 docker 桌面通过 docker build 构建一个新映像。看来构建上下文可能不可用于构建过程。
FROM apache/airflow:2.8.0-python3.8
ADD /tmp/requirements.txt .
RUN pip install apache-airflow==2.2.0 -r requirements.txt
它会产生以下错误:
❯ docker build - < Dockerfile_local
[+] Building 3.3s (6/7) docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 195B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/apache/airflow:2.8.0-python3.8 3.3s
=> [internal] load build context 0.0s
=> => transferring context: 2B 0.0s
=> CANCELED [1/3] FROM docker.io/apache/airflow:2.8.0-python3.8@sha256:6d9a8f90ad5d6005f81b9a059134237f4f970b91d282799 0.0s
=> => resolve docker.io/apache/airflow:2.8.0-python3.8@sha256:6d9a8f90ad5d6005f81b9a059134237f4f970b91d282799a350f7dda 0.0s
=> => sha256:6d9a8f90ad5d6005f81b9a059134237f4f970b91d282799a350f7ddace6ab1a5 1.61kB / 1.61kB 0.0s
=> => sha256:d7d27a316f5cd64a0b6eb87047ac04203c8b667a2c363e623bc326e8ea6665d7 25.67kB / 25.67kB 0.0s
=> => sha256:180b4f3737b0430931e906094d02b0728912110b90c83ae7ffc467a0b01ba4fa 4.47kB / 4.47kB 0.0s
=> ERROR [2/3] ADD /tmp/requirements.txt . 0.0s
------
> [2/3] ADD /tmp/requirements.txt .:
------
Dockerfile:2
--------------------
1 | FROM apache/airflow:2.8.0-python3.8
2 | >>> ADD /tmp/requirements.txt .
3 | RUN pip install apache-airflow==2.2.0 -r requirements.txt
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref f9dd9b67-5ecf-41ed-beed-87bfda7e1dfd::8el50kgcmxh0ay9r8ue7zhgp1: failed to walk /var/lib/docker/tmp/buildkit-mount348437173/tmp: lstat /var/lib/docker/tmp/buildkit-mount348437173/tmp: no such file or directory
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/10tveo6gaue4pbz92r0mnwvgc
有没有办法像这样与构建上下文共享文件?
将requirements.txt移至与Dockerfile相同的路径,然后将ADD命令更改为:
添加需求.txt .
如果这有效,thsi 将作为健全性检查,允许您将问题范围缩小到 tmp 路径。