docker / docker/buildx

Error handling inconsistency when adding multiple files from an absolute path outside the Docker build context

Open
#1,899 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/cli status/needs-investigation
Dominant language
Go
Stars
4.5k
Forks
682
Avg merge
2d 14h
Merged PRs (30d)
29

Description

Contributing guidelines
I've found a bug and checked that ...
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem
Description

When adding multiple files from an absolute path, which is outside the docker build context, only the last line to add files is marked as ERROR, and all the previous ones are marked as CACHED, which indicates that it was able to add the file.

Expected behaviour

A visual ERROR for 2/3 instead of CACHED.

Actual behaviour
➤  docker buildx build .
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
[+] Building 0.5s (7/7) FINISHED                                                                                                                                                      
 => [internal] load .dockerignore                                                                                                                                                0.0s
 => => transferring context: 2B                                                                                                                                                  0.0s
 => [internal] load build definition from Dockerfile                                                                                                                             0.0s
 => => transferring dockerfile: 91B                                                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                                 0.4s
 => [1/3] FROM docker.io/library/alpine@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1                                                                  0.0s
 => => resolve docker.io/library/alpine@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1                                                                  0.0s
 => [internal] load build context                                                                                                                                                0.0s
 => => transferring context: 2B                                                                                                                                                  0.0s
 => CACHED [2/3] ADD /tmp/file1 file1                                                                                                                                            0.0s
 => ERROR [3/3] ADD /tmp/file2 file2                                                                                                                                             0.0s
------
 > [3/3] ADD /tmp/file2 file2:
------
Dockerfile:4
--------------------
   2 |     
   3 |     ADD /tmp/file1 file1
   4 | >>> ADD /tmp/file2 file2
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 779frby5mzfnvh0rbzh87v1uu::9him080gk30ca77e8gi95mer5: "/tmp/file2": not found
Buildx version

github.com/docker/buildx v0.10.5 86bdced

Docker info
Client: Docker Engine - Community
 Version:    24.0.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.5
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.18.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 2
  Running: 1
  Paused: 0
  Stopped: 1
 Images: 252
 Server Version: 24.0.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
 runc version: v1.1.7-0-g860f061
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.19.0-45-generic
 Operating System: Ubuntu 22.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 20
 Total Memory: 31.03GiB
 Name: samuel-celestia
 ID: I3LI:ACFC:5SWU:VAWC:K6MZ:JKVZ:ST6F:NMKB:UWU2:DJLS:CIOV:XQV7
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: smuu
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
Builders list
NAME/NODE               DRIVER/ENDPOINT             STATUS   BUILDKIT                              PLATFORMS
awesome_goldwasser      docker-container                                                           
  awesome_goldwasser0   unix:///var/run/docker.sock inactive                                       
epic_wilbur             docker-container                                                           
  epic_wilbur0          unix:///var/run/docker.sock inactive                                       
wonderful_mirzakhani    docker-container                                                           
  wonderful_mirzakhani0 unix:///var/run/docker.sock inactive                                       
youthful_goldwasser *   docker-container                                                           
  youthful_goldwasser0  unix:///var/run/docker.sock running  v0.11.6                               linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386
default                 docker                                                                     
  default               default                     running  v0.11.7-0.20230525183624-798ad6b0ce9f linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386
Configuration
FROM alpine

ADD /tmp/file1 file1
ADD /tmp/file2 file2
Build logs

No response

Additional info

Happy to provide more information if needed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the shown Dockerfile and docker buildx build . command, focusing on how the build output labels the two invalid absolute-path ADD steps. The issue is done when each affected step is visibly reported as ERROR rather than earlier steps being shown as CACHED.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, dockerfile, go
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.