docker / docker/buildx

Bake: confusing error message on multiple undefined variables

Open
#3,158 4 comments 0 reactions 1 assignee View on GitHub

@jsternberg is already working on this.

Since Aug 15, 2025.

status/needs-investigation status/triage
Dominant language
Go
Stars
4.5k
Forks
682
Avg merge
2d 14h
Merged PRs (30d)
29

Description

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

The "docker-language-server" in Visual Studio Code is saying "Invalid expression (variable cycle not allowed to registry)"

I am not sure what this means.

All the examples in the docs use the same image for "cache-from" and "cache-to", so I am confused why I can't do that.

target "ubuntu" {
  context = "ci/ubuntu"
  name = sanitize("ubuntu_${ubuntu_version.to}")
  tags = ["${HARBOR_REGISTRY_PREFIX}/ci/ubuntu:${ubuntu_version.to}"]
  matrix = {
    ubuntu_version = [
      {
        from = "noble"
        to = "noble-rootless"
      },
      {
        from = "jammy"
        to = "jammy-rootless"
      },
      {
        from = "focal"
        to = "focal-rootless"
      }
    ]
  }
  args = {
    FROM_TAG = ubuntu_version.from
  }
  inherits = ["_common"]
  cache-to = [
    {
      type=registry,
      ref="${HARBOR_REGISTRY_PREFIX}/ci/ubuntu:${ubuntu_version.to}-build-cache",
      mode=max,
    },
  ]
  cache-from = [ 
    {
      type=registry,
      ref="${HARBOR_REGISTRY_PREFIX}/ci/ubuntu:${ubuntu_version.to}-build-cache"
    },
  ]
}

Image

Expected behaviour

I expect the build cache to be pushed to "${HARBOR_REGISTRY_PREFIX}/ci/ubuntu:${ubuntu_version.to}-build-cache" and pulled from the same place.

Actual behaviour

The "docker-language-server" in Visual Studio Code is saying "Invalid expression (variable cycle not allowed to registry)"

Buildx version

github.com/docker/buildx v0.23.0 28c90ea

Docker info
Client: Docker Engine - Community
 Version:    28.1.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.23.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.35.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 4
  Running: 1
  Paused: 0
  Stopped: 3
 Images: 34
 Server Version: 28.1.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: true
 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: 05044ec0a9a75232cad458027ca83437aae3f4da
 runc version: v1.2.5-0-g59923ef
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  rootless
  cgroupns
 Kernel Version: 6.11.0-24-generic
 Operating System: Ubuntu 24.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 31.05GiB
 Name: mhm
 ID: 24f3ada6-172a-47d5-bbf0-25f34f871c96
 Docker Root Dir: /home/mhm/.local/share/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No cpuset support
WARNING: No io.weight support
WARNING: No io.weight (per device) support
WARNING: No io.max (rbps) support
WARNING: No io.max (wbps) support
WARNING: No io.max (riops) support
WARNING: No io.max (wiops) support
Builders list
NAME/NODE               DRIVER/ENDPOINT                         STATUS    BUILDKIT   PLATFORMS
docker-container        docker-container                                             
 \_ docker-container0    \_ unix:///run/user/1000/docker.sock   running   v0.20.2    linux/amd64 (+3), linux/386
remote                  remote                                                       
 \_ remote0              \_ tcp://redacted-company-buildkit-server:1234         running   v0.21.0    linux/amd64 (+3), linux/386
default*                docker                                                       
 \_ default              \_ default                             running   v0.21.0    linux/amd64 (+3), linux/386
rootless                docker                                                       
 \_ rootless             \_ rootless                            running   v0.21.0    linux/amd64 (+3), linux/386
Configuration
mhm@mhm:~/Documents/continuous-integration$ time docker buildx bake --set=*.target=test --set=*.output=type=cacheonly ubuntu
[+] Building 0.0s (0/1)                                                                                                                                              docker:default
 => [internal] load local bake definitions                                                                                                                                     0.0s
docker-bake.hcl:67
[+] Building 0.0s (1/1) FINISHED                                                                                                                                     docker:default
 => [internal] load local bake definitions                                                                                                                                     0.0s
 => => reading docker-bake.hcl 15.93kB / 15.93kB                                                                                                                               0.0s
  67 | >>>   cache-to = [
  68 | >>>     {
  69 | >>>       type=registry,
  70 | >>>       ref="${HARBOR_REGISTRY_PREFIX}/ci/ubuntu:${ubuntu_version.to}-build-cache",
  71 | >>>       mode=max,
  72 | >>>     },
  73 | >>>   ]
  74 |       cache-from = [ 
--------------------
ERROR: docker-bake.hcl:67,14-73,4: Invalid expression; variable cycle not allowed for registry

real    0m0.125s
user    0m0.120s
sys     0m0.039s
Build logs

Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.