I trying to build a jenkins image starting FROM jenkins/jenkins:2.440.1-lts
and it fails with error: failed to resolve source metadata for docker.io
If I run docker build .
docker build .
[+] Building 30.1s (2/2) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.49kB 0.0s
=> ERROR [internal] load metadata for docker.io/jenkins/jenkins:2.440.1-lts 30.0s
------
> [internal] load metadata for docker.io/jenkins/jenkins:2.440.1-lts:
------
Dockerfile:1
--------------------
1 | >>> FROM jenkins/jenkins:2.440.1-lts
2 |
3 | ADD --chown=1000:1000 plugins.txt /var/jenkins_home/
--------------------
ERROR: failed to solve: DeadlineExceeded: DeadlineExceeded: DeadlineExceeded: jenkins/jenkins:2.440.1-lts: failed to resolve source metadata for docker.io/jenkins/jenkins:2.440.1-lts: failed to authorize: DeadlineExceeded: failed to fetch anonymous token: Get "https://auth.docker.io/token?scope=repository%3Ajenkins%2Fjenkins%3Apull&service=registry.docker.io": dial tcp 54.196.99.49:443: i/o timeout
If I run docker pull all is good:
docker pull jenkins/jenkins:2.440.1-lts
2.440.1-lts: Pulling from jenkins/jenkins
7bb465c29149: Pull complete
c18f106040a7: Pull complete
f826d0f09907: Pull complete
bc3128b515a7: Pull complete
45dc40627eb2: Pull complete
ce448981c34b: Pull complete
f2e0835aa94f: Pull complete
bce8503d6e45: Pull complete
3353a3a64a1f: Pull complete
5b9963212983: Pull complete
0a769ec2c083: Pull complete
6bbf8192cfe6: Pull complete
Digest: sha256:01c0b0cf789fa24253090fccea264df223b5e09b14a0ea59f0847c70bdc0f31c
Status: Downloaded newer image for jenkins/jenkins:2.440.1-lts
docker.io/jenkins/jenkins:2.440.1-lts
If I run docker build AFTER docker pull
the build process is good since the image is already present locally.
docker build .
[+] Building 2.4s (12/13) docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.49kB 0.0s
=> [internal] load metadata for docker.io/jenkins/jenkins:2.440.1-lts 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [1/9] FROM docker.io/jenkins/jenkins:2.440.1-lts 0.2s
=> [internal] load build context 0.0s
=> => transferring context: 6.94kB 0.0s
=> [2/9] ADD --chown=1000:1000 plugins.txt /var/jenkins_home/ 0.0s
docker info
Client: Docker Engine - Community
Version: 27.3.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.17.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.29.7
Path: /usr/libexec/docker/cli-plugins/docker-compose
The environment is: no direct internet connection, only through a proxy. It looks like docker build
does not respect the Environment set at /etc/systemd/system/docker.service.d/http-proxy.conf
. This config is respected by docker pull
.
The DNS works as expected (so docker run also knows how to download an image which is not present locally):
docker run --rm busybox nslookup docker.io
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
2fce1e0cdfc5: Pull complete
Digest: sha256:c230832bd3b0be59a6c47ed64294f9ce71e91b327957920b6929a0caa8353140
Status: Downloaded newer image for busybox:latest
Server: 172.16.0.2
Address: 172.16.0.2:53
Non-authoritative answer:
Name: docker.io
Address: 3.224.227.198
Name: docker.io
Address: 44.219.3.189
Name: docker.io
Address: 44.193.181.103
Non-authoritative answer:
Name: docker.io
Address: 2600:1f18:2148:bc02:4f78:625e:1ac1:714c
Name: docker.io
Address: 2600:1f18:2148:bc01:2822:9e2a:c82a:af0
Name: docker.io
Address: 2600:1f18:2148:bc00:a518:1574:fea8:ccdb
I even tried to put proxy IP addresses instead FQDNs same issue. The same error can be found in jounalctl -u docker.service. Same error happens if I add/use /etc/docker/daemon.json
.
I tried adding this docker client config but still no luck:
cat ~/.docker/config.json
{
"proxies": {
"default": {
"httpProxy": "http://proxy.domain.internal:3128",
"httpsProxy": "http://proxy.domain.internal:3129",
"noProxy": "*.domain.internal,127.0.0.1"
}
}
}
I also tried this hack with docker buildx create --use --driver-opt
:
docker buildx create --use --driver-opt env.http_proxy=http//proxy.domain.internal:3128 --driver-opt env.https_proxy=http://proxy.domain.internal:3128 --driver-opt '"env.no_proxy='*.domain.internal,127.0.0.1'"'
inspiring_matsumoto
docker buildx build .
[+] Building 35.7s (3/3) FINISHED docker-container:inspiring_matsumoto
=> [internal] booting buildkit 5.2s
=> => pulling image moby/buildkit:buildx-stable-1 4.6s
=> => creating container buildx_buildkit_inspiring_matsumoto0 0.6s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.49kB 0.0s
=> ERROR [internal] load metadata for docker.io/jenkins/jenkins:2.440.1-lts 30.3s
------
> [internal] load metadata for docker.io/jenkins/jenkins:2.440.1-lts:
------
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
Dockerfile:1
I also tried this and still same error:
docker build --build-arg HTTP_PROXY=http://proxy.domain.internal:3128 \
--build-arg HTTPS_PROXY=http://proxy.domain.internal:3128 --build-arg NO_PROXY="*.domain.internal,127.0.0.1" \
--build-arg http_proxy=http://proxy.domain.internal:3128 --build-arg https_proxy=http://proxy.domain.internal:3128 \
--build-arg no_proxy="*.domain.internal,127.0.0.1"
[+] Building 30.1s (2/2) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.49kB 0.0s
=> ERROR [internal] load metadata for docker.io/jenkins/jenkins:2.440.1-lts 30.0s
------
> [internal] load metadata for docker.io/jenkins/jenkins:2.440.1-lts:
------
Dockerfile:1
--------------------
1 | >>> FROM jenkins/jenkins:2.440.1-lts
2 |
3 | ADD --chown=1000:1000 plugins.txt /var/jenkins_home/
--------------------
ERROR: failed to solve: DeadlineExceeded: DeadlineExceeded: DeadlineExceeded: jenkins/jenkins:2.440.1-lts: failed to resolve source metadata for docker.io/jenkins/jenkins:2.440.1-lts: failed to authorize: DeadlineExceeded: failed to fetch anonymous token: Get "https://auth.docker.io/token?scope=repository%3Ajenkins%2Fjenkins%3Apull&service=registry.docker.io": dial tcp 54.196.99.49:443: i/o timeout
I tried all the above with the IP address of the proxy (not the FQDN) and receive the same error. Did even docker system prune -a
, systemctl restart docker
, rebooted the instance and docker build --no-cache
just to have a clean env and Again docker pull
works! docker build does not respect the proxy settings.