Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml labels values get mixed up in bake #1631

Closed
kohtala opened this issue Feb 15, 2023 · 1 comment
Closed

yaml labels values get mixed up in bake #1631

kohtala opened this issue Feb 15, 2023 · 1 comment

Comments

@kohtala
Copy link

kohtala commented Feb 15, 2023

Running docker buildx bake --print on docker-compose.yml

services:
  a:
    build:
      tags: [a]
      labels:
        a: A
        b: B
  b:
    build:
      tags: [b]
      labels:
        c: C
        d: D
        e: E

Gives

{
  "group": {
    "default": {
      "targets": [
        "a",
        "b"
      ]
    }
  },
  "target": {
    "a": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "labels": {
        "a": "B",
        "b": "B"
      },
      "tags": [
        "a"
      ]
    },
    "b": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "labels": {
        "c": "C",
        "d": "C",
        "e": "C"
      },
      "tags": [
        "b"
      ]
    }
  }
}

The labels values are mixed up.

With simple Dockerfile of FROM scratch you get similar results in the images using default docker builder:

$ docker image inspect a

[
    {
        "Id": "sha256:05c62be58f310cc2e2937be5c75be69ce11642b45fa344bf67f6d7012e9befcc",
        "RepoTags": [
            "a:latest"
        ],
        "RepoDigests": [],
        "Parent": "",
        "Comment": "",
        "Created": "0001-01-01T00:00:00Z",
        "Container": "",
        "ContainerConfig": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": null,
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "DockerVersion": "",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "/",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "a": "B",
                "b": "B"
            }
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 0,
        "VirtualSize": 0,
        "GraphDriver": {
            "Data": null,
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers"
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

$ docker image inspect b

[
    {
        "Id": "sha256:5a77f21250176bf210ebf363346a339aa9df70e17c4fc5519b354772ab3ad226",
        "RepoTags": [
            "b:latest"
        ],
        "RepoDigests": [],
        "Parent": "",
        "Comment": "",
        "Created": "0001-01-01T00:00:00Z",
        "Container": "",
        "ContainerConfig": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": null,
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "DockerVersion": "",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "/",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "c": "E",
                "d": "E",
                "e": "E"
            }
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 0,
        "VirtualSize": 0,
        "GraphDriver": {
            "Data": null,
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers"
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

$ docker buildx version
github.com/docker/buildx v0.10.2 00ed17d
$ dpkg -s docker-buildx-plugin

Package: docker-buildx-plugin
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 68883
Maintainer: Docker <[email protected]>
Architecture: amd64
Source: docker-ce (5:23.0.0-1~ubuntu.20.04~focal)
Version: 0.10.2-1~ubuntu.20.04~focal
Replaces: docker-ce-cli
Enhances: docker-ce-cli
Description: Docker Buildx cli plugin.
Homepage: https://github.com/docker/buildx
$ docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS  BUILDKIT PLATFORMS
default * docker
  default default         running 23.0.1   linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6

@jedevc
Copy link
Collaborator

jedevc commented Feb 15, 2023

Should be fixed by #1582

This fix will be included in the next patch release of buildx, v0.10.3 at some point in the next week or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants