Closed grahamb closed 1 year ago
This comment in pkg/compose/build.go
is suspect:
// Finally, standard proxy variables based on the Docker client configuration are added, but will not overwrite
// any values if already present.
Do you have some proxy configuration declared in .docker/config.json
?
Yes, I do:
{
"proxies": {
"default": {
"httpProxy": "http://bby-vcontrol-proxy.its.sfu.ca:8080",
"httpsProxy": "http://bby-vcontrol-proxy.its.sfu.ca:8080",
"noProxy": "localhost,127.0.0.1,10.28.130.135,sfu.ca,www.sfu.ca,*.sfu.ca,*.its.sfu.ca,.sfu.ca,.its.sfu.ca,its.sfu.ca,github.sfu.ca,lookups.twilio.com,api.twillio.com"
}
}
}
ok, do you have the same behavior running docker buildx build .
with your service's Dockerfile ?
No - I mentioned that in the opening post, but it's admittedly kind of buried in there.
If I build the image with Docker (not docker-compose), the proxy variables output by the build are what I would expect:
❯ docker buildx build --tag local/dev:latest --progress plain --no-cache . #0 building with "default" instance using docker driver #1 [internal] load .dockerignore #1 transferring context: 210B done #1 DONE 0.0s #2 [internal] load build definition from Dockerfile #2 transferring dockerfile: 1.05kB done #2 DONE 0.0s #3 [internal] load metadata for docker.io/library/alpine:latest #3 DONE 0.3s #4 [1/2] FROM docker.io/library/alpine:latest@sha256:7144f7bab3d4c2648d7e59409f15ec52a18006a128c733fcff20d3a4a54ba44a #4 CACHED #5 [2/2] RUN env | grep -i proxy #5 0.322 HTTPS_PROXY=http://bby-vcontrol-proxy.its.sfu.ca:8080 #5 0.322 no_proxy=localhost,127.0.0.1,10.28.130.135,sfu.ca,www.sfu.ca,*.sfu.ca,*.its.sfu.ca,.sfu.ca,.its.sfu.ca,its.sfu.ca,github.sfu.ca,lookups.twilio.com,api.twillio.com #5 0.322 NO_PROXY=localhost,127.0.0.1,10.28.130.135,sfu.ca,www.sfu.ca,*.sfu.ca,*.its.sfu.ca,.sfu.ca,.its.sfu.ca,its.sfu.ca,github.sfu.ca,lookups.twilio.com,api.twillio.com #5 0.322 https_proxy=http://bby-vcontrol-proxy.its.sfu.ca:8080 #5 0.322 http_proxy=http://bby-vcontrol-proxy.its.sfu.ca:8080 #5 0.322 HTTP_PROXY=http://bby-vcontrol-proxy.its.sfu.ca:8080 #5 DONE 0.4s #6 exporting to image #6 exporting layers 0.0s done #6 writing image sha256:c3fb9a84471a3c7ab852233e9dedb028f5114813d610ce20c3939d891147f6e0 done #6 naming to docker.io/local/dev:latest done #6 DONE 0.0s
the root cause is a variable collision iterating proxy config in .docker/config.json
, a very common Go issue which strikes back on a regular basis
Description
This sounds very strange, but it appears that docker-compose v2.20.3 is rewriting environment variables, specifically http_proxy and https_proxy (and their upper-case variants).
I have http(s)_proxy and no_proxy variables set in my shell, in ~/.docker/config.json, and in /etc/systemd/system/docker.service.d/http-proxy.conf
My shell variables:
I have a very simple test Dockerfile:
If I build the image with Docker (not docker-compose), the proxy variables output by the build are what I would expect:
However, if I do a
docker-compose build
, the variables get re-written:Note that my
no_proxy
andNO_PROXY
variables have been changed and match thehttps_proxy
et al variables.I downgraded to the previous docker-compose release (2.20.2), and the
docker-compose build
command returns the expected output.Note that
no_proxy
andNO_PROXY
match what is set in my shell.With the
alpine:latest
image, it's changingno_proxy
andNO_PROXY
to the values ofhttps_proxy
. However, in other images (e.g.ubuntu:latest
, and some other custom-built images) it's the opposite;https_proxy
(and the uppercase variants) are set to the value ofno_proxy
. For example, withubuntu:latest
:Steps To Reproduce
docker-compose --progress plain build --no-cache
Expected behaviour: environment variables output during the build should match those as set in the shell Actual behaviour: docker-compose is rewriting the variables' values
Compose Version
Docker Environment
Anything else?
No response