Skip to content

yaml labels values get mixed up in bake #1631

@kohtala

Description

@kohtala

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 <support@docker.com>
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions