[BUG] docker-compose does not load ~/.docker/config.json
Description
I want the docker-compose to behave the same as the docker command. In this case it is to load all the configuration by default from ~/.docker/config.json.
At the moment docker-compose won't do that by default. When there's an environment variable DOCKER_CONFIG, docker-compose respects its content, e.g. DOCKER_CONFIG=~/.docker; docker-compose build works.
Can you use the default value (~/.docker/config.json) when the DOCKER_CONFIG variable is not set to align with docker executable behaviour? Thoughts?
Steps To Reproduce
- Create a project with Dockerfile and docker-compose.yaml Dockerfile
FROM container-registry.oracle.com/os/oraclelinux:8-slim
RUN microdnf install nc
docker-compose.yaml
services:
mycontainer:
build: .
container_name: mycontainer
- Configure for example proxy variable in ~/.docker/config.json, pointing to a proxy server.
"proxies": {
"default": {
"httpProxy": "nonexistingproxy.com:80"
}
}
- run
docker build ./Docker commands respect the config.json by default and fails installing the package on non-existing proxy unavailability. - run
docker-compose buildDocker-compose does not respect config.json => image is build succesfully => didn't respect the proxy settings in config.json - run
DOCKER_CONFIG=~/.docker; docker-compose build=> image build fails => proxy settings were respected.
- make sure you remove cached images between each command.
Compose Version
❯ docker compose version
Docker Compose version 2.20.3
❯ docker-compose version
Docker Compose version 2.20.3
Docker Environment
Client:r info
Version: 24.0.2-rd
Context: rancher-desktop
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.11.0
Path: /Users/.../.docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: 2.20.3
Path: /Users/.../.docker/cli-plugins/docker-compose
dev: Docker Dev Environments (Docker Inc.)
Version: v0.0.5
Path: /Users/.../.docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.17
Path: /Users/.../.docker/cli-plugins/docker-extension
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /Users/.../.docker/cli-plugins/docker-sbom
scan: Docker Scan (Docker Inc.)
Version: v0.23.0
Path: /Users/.../.docker/cli-plugins/docker-scan
Server:
Containers: 2
Running: 0
Paused: 0
Stopped: 2
Images: 20
Server Version: 23.0.6
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: cgroupfs
Cgroup Version: 1
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: 1fbd70374134b891f97ce19c70b6e50c7b9f4e0d
runc version: 860f061b76bb4fc671f0f9e900f7d80ff93d4eb7
init version:
Security Options:
seccomp
Profile: builtin
Kernel Version: 6.1.30-0-virt
Operating System: Alpine Linux v3.18
OSType: linux
Architecture: aarch64
CPUs: 4
Total Memory: 5.79GiB
Name: lima-rancher-desktop
ID: ...
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http://something
HTTPS Proxy: http://something
No Proxy: something
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Anything else?
No response
You might be running into #10902 in v2.20.3, which regressed when fixing proxy handling for a different issue 😓
But in general, Compose does respect ~/.docker/config.json.
~/.docker/config.json`
{
"auths": {},
"credsStore": "desktop",
"proxies": {
"default": {
"httpProxy": "insecure.proxy.localhost:80",
"httpsProxy": "secure.proxy.localhost:80",
"noProxy": "127.0.0.1"
}
},
"currentContext": "desktop-linux",
}
Dockerfile
FROM alpine
RUN env | grep -i proxy && false
Build with docker compose build --no-cache:
> [mycontainer 2/2] RUN env | grep -i proxy && false:
0.100 HTTPS_PROXY=secure.proxy.localhost:80
0.100 no_proxy=127.0.0.1
0.100 NO_PROXY=127.0.0.1
0.100 https_proxy=secure.proxy.localhost:80
0.100 http_proxy=insecure.proxy.localhost:80
0.100 HTTP_PROXY=insecure.proxy.localhost:80
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.