buildx: Buildx doesn't respect insecure registries

Contributing guidelines

I’ve found a bug and checked that …

  • … the documentation does not mention anything about my problem
  • … there are no open or closed issues that are related to my problem

Description

Using the buildx plugin the insecure registries are not working after the latest update. By default it tries HTTPS (443). Issue visible on multiple systems.

Expected behaviour

Use port 80

Actual behaviour

Uses port 443

Buildx version

github.com/docker/buildx v0.12.1 30feaa1

Docker info

Client: Docker Engine - Community
 Version:    25.0.1
 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.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 25.0.1
 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 splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: a1496014c916f9e62104b33d1bb5bd03b0858e59
 runc version: v1.1.11-0-g4bccb38
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 5.15.133.1-microsoft-standard-WSL2
 Operating System: Ubuntu 22.04.3 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 11.58GiB
 Name: Re4zOon-ThinkBook
 ID: WYZY:FVFE:G4KA:VOCH:RMQ7:LJSQ:FEDQ:BUQ2:BR63:KVHY:WAFU:C2XH
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  our-registry
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

Builders list

NAME/NODE     DRIVER/ENDPOINT STATUS  BUILDKIT             PLATFORMS
default *     docker
  default     default         running v0.12.4+3b6880d2a00f linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/386
desktop-linux                 error

Cannot load builder desktop-linux: protocol not available

Configuration

FROM our-registry/base-images/debian:latest

RUN echo "hello"

Build logs

❯ docker build .
[+] Building 0.1s (2/2) FINISHED                                                                                                                                                                   docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                         0.0s
 => => transferring dockerfile: 112B                                                                                                                                                                         0.0s
 => ERROR [internal] load metadata for our-registry/base-images/debian:latest                                                                                                                   0.0s
------
 > [internal] load metadata for our-registry/base-images/debian:latest:
------
Dockerfile:1
--------------------
   1 | >>> FROM our-registry/base-images/debian:latest
   2 |
   3 |     RUN echo "hello"
--------------------
ERROR: failed to solve: our-registry/base-images/debian:latest: failed to do request: Head "https://our-registry/v2/base-images/debian/manifests/latest": dial tcp 192.168.1.1:443: connect: no route to host

Additional info

Insecure registry is set properly in /etc/docker/daemon.json:

❯ cat /etc/docker/daemon.json
{
  "insecure-registries":["http://our-registry", "our-registry"],
  "hosts": ["unix:///mnt/wsl/shared-docker/docker.sock"]
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 27 (3 by maintainers)

Most upvoted comments

Hi,

This is still not solved, can you please reopen it? @crazy-max

buildx: Docker Buildx (Docker Inc.)  
Version:  v0.17.1  
Path:     /usr/libexec/docker/cli-plugins/docker-buildx  

I have been pulling my hair for a day now trying to understand how this actually works, because it is fairly schizofrenic.

So adding an http mirror into daemon.json, will cause most of the “normal” docker commands to actually use that mirror as is (namely, use http).

However, this also makes buildkit use that mirror, but instead call it via https (WTF?). Not only that, it will then wait for a timeout on EVERY request (30-60 seconds, even more WTF) before moving onto calling the docker hub registry directly, making it seemingly “work” but completely defunct because pulling the image takes forever. Just getting metadata takes 90 seconds for me.

The only way I managed to get it to work, is to declare a NEW builder with a NEW config that configures the mirror as a repository with http = true, but this instead gives me another builder that isn’t used by default when invoking docker build, only when calling docker buildx (woot), and most of CI builds (where I use this) is actually building behind the scenes via docker compose, I have no clue how that would work. I also seem to need to add --output flag to the build command to actually store the image, this is a lot of hoops to get this working.

This also seem to have been an ongoing issue for the past 6 years or so (when trying to follow the various issues filed for this), where to me, since it obviously uses the mirror configuration from daemon.json (and knows about it), why wouldn’t it also respect the http scheme like the rest of the docker tooling?

What is this https enforcement actually trying to enforce?

Same problem on a fresh install of Docker 26.1.2 in an VM with Oracle Linux 8.9. Executing the command “docker build .” results in failure if the base image is in an insecure registry. Looks like the “insecure-registries” property in the file “/etc/docker/daemon.json” is still being ignored.

I can manually pull the same image without problem.

The workaround for now is using “export DOCKER_BUILDKIT=0”.

docker builder version github.com/docker/buildx v0.14.0 171fcbe

Example of a docker compose setup:

[user@host]# docker compose --verbose up -d --build --force-recreate
TRAC[0000] Docker Desktop integration not enabled       
DEBU[0000] using default config store "/home/user/.docker/buildx" 
[+] Building 0.0s (2/2) FINISHED                                                                                                                                                                    docker:default
 => [app internal] load build definition from Dockerfile                                                                                                                                                      0.0s
 => => transferring dockerfile: 439B                                                                                                                                                                          0.0s
 => ERROR [app internal] load metadata for my.private.registry:1234/docker/amazoncorretto:17                                                                                                              0.0s
------
 > [app internal] load metadata for my.private.registry:1234/docker/amazoncorretto:17:
------
DEBU[0000] using default config store "/home/user/.docker/buildx" 
DEBU[0000] serving grpc connection                      
DEBU[0000] stopping session                              span="load buildkit capabilities"
DEBU[0000] serving grpc connection                      
DEBU[0000] stopping session                             
DEBU[0000] serving grpc connection                      
DEBU[0000] stopping session                             
failed to solve: my.private.registry:1234/docker/amazoncorretto:17: failed to resolve source metadata for my.private.registry:1234/docker/amazoncorretto:17: failed to do request: Head "https://my.private.registry:1234/v2/docker/amazoncorretto/manifests/17": remote error: tls: unrecognized name

v0.13.1 fail use http registry. My flow shown as below

    - docker buildx create --use --config buildx-config.toml
    - docker buildx build --build-arg RELEASE=$RELEASE --build-arg DATE=$DATE --push --platform linux/amd64 . -t "$CI_REGISTRY_IMAGE:$RELEASE" -t "$CI_REGISTRY_IMAGE:$RELEASE-$DATE" -f Dockerfile

buildx-config.toml

[registry."192.168.0.2:5050"]
  insecure = true
  http = true

Buildx keep requesting https, in the end locking to old version with --driver-opt image=moby/buildkit:v0.12.2.

Hi,

Any updates? Its blocking our second upgrade schedule for our jenkins’.

#Step1 # craete buildx config file on your local machine mkdir -p ~/.docker/buildx cat > ~/.docker/buildx/buildkitd.toml << EOF debug = true [registry.“114.67.223.128:5080”] http = true insecure = true

[registry.“http://114.67.223.128:5080”] http = true insecure = true EOF

#Step2 create builder with the config file specified docker buildx create --name mybuilder
–driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=10485760
–driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10485760
–driver-opt env.BUILDKIT_UNSAFE_HTTP=1
–config ~/.docker/buildx/buildkitd.toml
–use

You can try to fix the http request problem by specify --config param .It works for me .

@martadinata666, I have exactly same issues with exactly same commands in my ubuntu server, which blocks our CI/CD pipeline in Jenkins. 😦 However, it works in my mac with M2 chip.

Ubuntu Docker version:

# docker version
Client: Docker Engine - Community
 Version:           26.0.2
 API version:       1.45
 Go version:        go1.21.9
 Git commit:        3c863ff
 Built:             Thu Apr 18 16:27:07 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          26.0.2
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.9
  Git commit:       7cef0d9
  Built:            Thu Apr 18 16:27:07 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.31
  GitCommit:        e377cd56a71523140ca6ae87e30244719194a521
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
# docker buildx version
github.com/docker/buildx v0.14.0 171fcbe

Mac Docker version:

# docker version
Client:
 Cloud integration: v1.0.35+desktop.13
 Version:           26.0.0
 API version:       1.45
 Go version:        go1.21.8
 Git commit:        2ae903e
 Built:             Wed Mar 20 15:14:46 2024
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.29.0 (145265)
 Engine:
  Version:          26.0.0
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       8b79278
  Built:            Wed Mar 20 15:18:02 2024
  OS/Arch:          linux/arm64
  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:        de40ad0
# docker buildx version
github.com/docker/buildx v0.13.1-desktop.1 2368b2ee41873b948cb607251cec573ed00f00f9