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

Incorrect architecture in image manifest for multi-platform Dockerfiles #5677

Open
leocencetti opened this issue Jan 21, 2025 · 0 comments
Open

Comments

@leocencetti
Copy link

When building multi-platform Dockerfiles, the architecture recorded in the image manifest matches the platform specified via the CLI (--platform) instead of the actual architecture of the image.

Reproduction Steps

Consider the following (simplified) Dockerfile:

FROM --platform=${BUILDPLATFORM} ubuntu:jammy AS my-image

# This line prints 'ARCH=x86_64'
RUN echo "ARCH=$(uname -i)"

And build the image with:

# On an amd64 system
docker buildx build --platform linux/arm64 . -t my-image

Observed Behavior

Inspecting the image yields the following:

[
    {
        "Id": "sha256:384a346bab6247c7e6dd73a06b992fa3299afd886e32f8b82eb74276d6656829",
        "RepoTags": [
            "my-image:latest"
        ],
        "RepoDigests": [],
        "Parent": "",
        "Comment": "buildkit.dockerfile.v0",
        "Created": "2025-01-20T18:04:43.404596746+01:00",
        "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": [
                "/bin/bash"
            ],
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.opencontainers.image.ref.name": "ubuntu",
                "org.opencontainers.image.version": "22.04"
            }
        },
        "Architecture": "arm64",
        "Os": "linux",
        "Size": 77863303,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/0fdc01a9d4e3d5de7a7ea75b5980c183cc29afdda8d2d352cd051467f548b139/diff",
                "MergedDir": "/var/lib/docker/overlay2/rz00bs4kw09l4v8satsskjmc4/merged",
                "UpperDir": "/var/lib/docker/overlay2/rz00bs4kw09l4v8satsskjmc4/diff",
                "WorkDir": "/var/lib/docker/overlay2/rz00bs4kw09l4v8satsskjmc4/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:2573e0d8158209ed54ab25c87bcdcb00bd3d2539246960a3d592a1c599d70465",
                "sha256:62d5496453efca5975bad31cf253da349c6758a2acac0fbcc435110b7df68c4b"
            ]
        },
        "Metadata": {
            "LastTagTime": "2025-01-21T09:15:10.21212288+01:00"
        }
    }
]

The resulting image manifest has Architecture=arm64, but running uname -i (or checking the ELF headers of any binary) inside the container shows that the actual architecture is amd64. While this is a minor issue on system with QEMU configured (the correct executor is called), it can lead to execution format errors when running the images on other systems.

Expected Behavior

The manifest should reflect the actual architecture of the image (amd64 in this example), not the platform specified in the CLI.

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

1 participant