Repository navigation
Description
Description
I’m seeing non-deterministic behavior in docker build where an explicit --build-arg no_proxy=... sometimes gets overridden by the proxy default from Docker client config.json (proxies.default.noProxy).
Repeating the same build command produces different results across runs.
Reproduce
# allow to override Docker client proxies if necessary
ARG http_proxy
ARG https_proxy
ARG no_proxy
FROM ubuntu:24.04
# redeclare ARGs
ARG http_proxy
ARG https_proxy
ARG no_proxy
RUN <<EOF
env | grep -i proxy
exit 1
EOF$HOME/.docker/config.json
{
"proxies":
{
"default": {
"noProxy": "my_default_noproxy_value_from_config.json"
}
}
}Repeatedly run docker build --build-arg no_proxy="my_cmdline_value" .
Expected behavior
When a user explicitly passes a build-arg on the command line, it should always take precedence over proxy defaults coming from ~/.docker/config.json.
For example, running:
docker build --build-arg no_proxy="my_cmdline_value" .should deterministically result in the build environment using:
no_proxy=my_cmdline_valueand/orNO_PROXY=my_cmdline_value
and it should never be replaced by proxies.default.noProxy (e.g. my_default_noproxy_value_from_config.json), regardless of how many times the build is repeated.
docker version
Client: Docker Engine - Community
Version: 25.0.2
API version: 1.44
Go version: go1.21.6
Git commit: 29cf629
Built: Thu Feb 1 00:23:03 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 25.0.2
API version: 1.44 (minimum version 1.24)
Go version: go1.21.6
Git commit: fce6e0c
Built: Thu Feb 1 00:23:03 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.28
GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0docker info
Client: Docker Engine - Community
Version: 25.0.2
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.5
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 9
Server Version: 25.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 splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.8.0-94-generic
Operating System: Ubuntu 24.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 15.25GiB
Name: galaxy-book2
ID: 4144eb0b-0084-4392-ac18-9c39ce54c05d
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: falseAdditional Info
Confirmed on 2 differents hosts, with 2 docker engines:(25.0.2 and 27.5.1)
Activity
Best2Two commentedon Jan 31, 2026
Hey @Wenzel are you working on fixing this issue? If not Can I work on it?
Wenzel commentedon Jan 31, 2026
Hey @Best2Two,
Thanks for looking at it !
I'm not a Docker contributor, so feel free to explore this issue.
Best2Two commentedon Jan 31, 2026
Thank you,
@thaJeztah Can you please assign it to me as a first time contributer? If that's not possible can I submit a PR on my own ?
thaJeztah commentedon Feb 1, 2026
I wonder if this is caused because you're defining these build-args in the Dockerfile; the
_proxy(and uppercase_PROXY) build-args are special-cased, pre-defined build-args;From the documentation; https://docs.docker.com/reference/dockerfile/#predefined-args
I wonder if because the dockerfile now defines build-args (but ONLY lowercase), detection of these overrides gets non-deterministic.
A quick test (without a
~/.docker/config.jsondefining defaults) shows that all these vars are set when passing build-args;Outputs;
crazy-max commentedon Mar 5, 2026
The root cause appears to be that Buildx can send both
build-arg:no_proxyfrom the CLI andbuild-arg:NO_PROXYfrom~/.docker/config.jsonbecause the override check is case-sensitive in Buildx, while BuildKit later matches proxy args case-insensitively and iterates a Go map, so the winning value depends on map iteration order.In Buildx, the relevant merge logic is around the
opt.BuildArgsandnode.ProxyConfigloops:buildx/build/opt.go
Lines 481 to 483 in 2ed4ece
buildx/build/opt.go
Lines 529 to 533 in 2ed4ece
And proxy defaults are currently emitted as uppercase keys in
buildx/store/storeutil/storeutil.go
Lines 28 to 52 in 2ed4ece
In BuildKit, the relevant logic is
proxyEnvFromBuildArgsin https://github.com/moby/buildkit/blob/5245d869d85d9c98f986b600584c332a3b001986/frontend/dockerfile/dockerfile2llb/convert.go#L2137-L2166 which usesstrings.EqualFoldduring map iteration.This makes explicit CLI
--build-arg no_proxy=...precedence non-deterministic whenever both case variants are present, so this looks like a real bug.