buildx icon indicating copy to clipboard operation
buildx copied to clipboard

--load and other cli flags regarding output behave different than expected

Open tg-freigmbh opened this issue 6 months ago • 2 comments

Contributing guidelines

I've found a bug and checked that ...

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

Description

docker buildx bake --help --load Shorthand for "--set=*.output=type=docker"

The help would indicate that its just a shorthand and nothing magical is going on

Expected behaviour

It just a shorthand and nothing magical is going on

Actual behaviour

docker buildx bake --load --print
[+] Building 0.0s (1/1) FINISHED                                                                                                                                                                                                                                                                                        
 => [internal] load local bake definitions                                                                                                                                                                                                                                                                         0.0s 
 => => reading docker-bake.hcl 59B / 59B                                                                                                                                                                                                                                                                           0.0s 
{
  "group": {
    "default": {
      "targets": [
        "default"
      ]
    }
  },
  "target": {
    "default": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "output": [
        {
          "dest": "hi.tar",
          "type": "tar"
        }
      ]
    }
  }
}

It is not possible to override the ouptut using --load

docker buildx bake  "--set=*.output=type=docker"  --print 
[+] Building 0.0s (1/1) FINISHED                                                                                                                                                                                                                                                                                        
 => [internal] load local bake definitions                                                                                                                                                                                                                                                                         0.0s 
 => => reading docker-bake.hcl 59B / 59B                                                                                                                                                                                                                                                                           0.0s 
{
  "group": {
    "default": {
      "targets": [
        "default"
      ]
    }
  },
  "target": {
    "default": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "output": [
        {
          "type": "docker"
        }
      ]
    }
  }
}

Using the longhand syntax its suddenly possible.

If it is intended that --load cant override the values speciefied in the buildfile this should be clearly documented, because this is highly confusing. I think it would be preferable if --load would behave exactly the same as the --set syntax

Buildx version

github.com/docker/buildx v0.22.0-desktop.1 b45d7a53aa26a5e76aae051acdb15775c0e178da

Docker info


Builders list

NAME/NODE           DRIVER/ENDPOINT     STATUS    BUILDKIT   PLATFORMS
default             docker
 \_ default          \_ default         running   v0.20.2    linux/amd64 (+3), linux/arm64, linux/arm (+2), linux/ppc64le, (2 more)
desktop-linux*      docker
 \_ desktop-linux    \_ desktop-linux   running   v0.20.2    linux/amd64 (+3), linux/arm64, linux/arm (+2), linux/ppc64le, (2 more)

Configuration

target "default" { output= ["type=tar,dest=hi.tar"]

}

Build logs


Additional info

No response

tg-freigmbh avatar Jun 10 '25 12:06 tg-freigmbh

Seems to be a regression since Buildx 0.14.0, I assume this is https://github.com/docker/buildx/pull/2336, specially this condition: https://github.com/docker/buildx/pull/2336/files#diff-fbe2fa23203f2ff05f06b6c0731ea90529f90906807483db76a79f6018781465R1460-R1464

crazy-max avatar Jun 10 '25 13:06 crazy-max

I think this works as expected as local/tar outputs are not image outputs and it would be incorrect to try to load them. Docs can be improved.

tonistiigi avatar Jun 10 '25 23:06 tonistiigi