cli icon indicating copy to clipboard operation
cli copied to clipboard

docker build ignores remote context download errors

Open TanvirTian opened this issue 1 month ago • 1 comments

Description

When Docker fails to download the files needed to build an image, it doesn't stop and show the download error. Instead, it keeps going and tries to contact the Docker daemon

Reproduce

  1. Run docker build with a remote URL that returns a 404 error
docker build https://httpbin.org/status/404
  1. Notice that Docker does not stop after the download fails.
  2. Docker continues and tries to contact the Docker daemon instead of returning the download error.
Image

Expected behavior

Docker should stop when the remote download fails and show the download error instead of sending the build context to the Docker daemon.

docker version

Client:
 Version:           unknown-version
 API version:       1.56
 Go version:        go1.27.1-X:nodwarf5
 Git commit:        unknown-commit
 Built:             unknown-buildtime
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          29.8.1
  API version:      1.56 (minimum version 1.40)
  Go version:       go1.27.1-X:nodwarf5
  Git commit:       464cd50c3d
  Built:            Fri Sep 18 16:01:02 2026
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v2.4.0
  GitCommit:        a7fe631d96c08fb14cf8eff0afdc280e99c30a94.m
 runc:
  Version:          1.5.1
  GitCommit:        1.5.1-1-0-gce23c4c-dirty
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    unknown-version
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc.)
    Version:  5.5.1
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 52
 Server Version: 29.8.1
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 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 splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: a7fe631d96c08fb14cf8eff0afdc280e99c30a94.m
 runc version: 1.5.1-1-0-gce23c4c-dirty
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 7.2.7-1-cachyos
 Operating System: CachyOS
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.53GiB
 Name: Tian
 ID: f9b383da-c02c-45f1-a7a8-0086e71c43e9
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false
 Firewall Backend: iptables
 EnableUserlandProxy: true
 UserlandProxyPath: /usr/bin/docker-proxy

Additional Info

Docker reports Cannot locate specified Dockerfile: Dockerfile instead of showing the error from downloading the remote files.

TanvirTian avatar Oct 09 '26 14:10 TanvirTian

Root cause is in cli/command/image/build.go, runBuild, the build.ContextTypeRemote branch (lines 261-265). It never returns the error from GetContextFromURL: on failure it only flushes the progress buffer in quiet mode, then falls through with a nil buildCtx. The code below then tars an empty context and sends it to the daemon. Every other branch (stdin, local, git) returns the error. Fix is up as #7374, mirrors those branches.

bunnysayzz avatar Oct 09 '26 16:10 bunnysayzz