Skip to content

[Bug]: container do support cross-platform build, but may fail with --platform specified in Dockerfile #372

@stevapple

Description

@stevapple

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

Given the following "cross-platform build" Dockerfile:

# syntax=docker/dockerfile:1

FROM --platform=${BUILDPLATFORM} ubuntu:20.04 AS build-stage
RUN uname -a > /build-info.txt

FROM scratch
WORKDIR /
COPY --from=build-stage /build-info.txt build-info.txt

Try to build it against an arch that ubuntu:20.04 isn't available in:

$ container build --arch loong64         
[+] Building 0.0s (0/1)                                                                                                                                                                                             
 => [resolver] fetching image...docker.io/library/ubuntu:20.04                                                                                                                                                 0.0s
Error: platform linux/loong64 for image docker.io/library/ubuntu:20.04 not found

Current behavior

container fails to build due to missing ubuntu:20.04 image for platform linux/loong64, even if it is explicitly marked to run as build platform (in this case, linux/arm64/v8).

Expected behavior

The Dockerfile should build on any host that ubuntu:20.04 supports. Here's a log from OrbStack for example:

$ docker build --platform linux/loong64 .
[+] Building 3.9s (8/8) FINISHED                                                                                                                                                           docker-container:builder
 => [internal] load build definition from Dockerfile                                                                                                                                                           0.0s
 => => transferring dockerfile: 245B                                                                                                                                                                           0.0s
 => resolve image config for docker-image://docker.io/docker/dockerfile:1                                                                                                                                      0.4s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:9857836c9ee4268391bb5b09f9f157f3c91bb15821bb77969642813b0d00518d                                                                                0.0s
 => => resolve docker.io/docker/dockerfile:1@sha256:9857836c9ee4268391bb5b09f9f157f3c91bb15821bb77969642813b0d00518d                                                                                           0.0s
 => [internal] load metadata for docker.io/library/ubuntu:20.04                                                                                                                                                0.3s
 => [internal] load .dockerignore                                                                                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                                                                                0.0s
 => [build-stage 1/2] FROM docker.io/library/ubuntu:20.04@sha256:8feb4d8ca5354def3d8fce243717141ce31e2c428701f6682bd2fafe15388214                                                                              2.5s
 => => resolve docker.io/library/ubuntu:20.04@sha256:8feb4d8ca5354def3d8fce243717141ce31e2c428701f6682bd2fafe15388214                                                                                          0.0s
 => => sha256:ecd83b6c354452b6a9979c7666bba16927f1e60e2afbfe6401dd6f87d5db8576 25.98MB / 25.98MB                                                                                                               2.1s
 => => extracting sha256:ecd83b6c354452b6a9979c7666bba16927f1e60e2afbfe6401dd6f87d5db8576                                                                                                                      0.3s
 => [build-stage 2/2] RUN uname -a > /build-info.txt                                                                                                                                                           0.5s
 => [stage-1 1/2] COPY --from=build-stage /build-info.txt build-info.txt                                                                                                                                       0.0s
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load

Environment

- OS: macOS Sequoia 15.5 (24F74)
- Xcode: Version 26.0 Beta 4 (17A5285i)
- Container: container CLI version 0.2.0 (build: release, commit: 3b5c253)

Relevant log output

Filtering the log data using "subsystem == "com.apple.container""
Timestamp                       Thread     Type        Activity             PID    TTL  
2025-07-25 12:48:26.225589+0800 0xf3d612   Info        0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] starting container-runtime-linux [uuid=buildkit]
2025-07-25 12:48:26.225598+0800 0xf3d612   Info        0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] configuring XPC server [uuid=buildkit]
2025-07-25 12:48:26.226477+0800 0xf3d612   Info        0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] starting XPC server [uuid=buildkit]
2025-07-25 12:48:26.227458+0800 0xf3d61f   Info        0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `dial` xpc handler [uuid=buildkit]
2025-07-25 12:48:26.227646+0800 0xf3d61f   Error       0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] handler for com.apple.container.sandbox/dial threw error invalidState: "cannot dial: container is not running" [uuid=buildkit]
2025-07-25 12:48:26.234939+0800 0xf3d612   Info        0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `bootstrap` xpc handler [uuid=buildkit]
2025-07-25 12:48:26.247754+0800 0xf3d62b   Info        0x0                  61291  0    container-network-vmnet: [com.apple.container:NetworkVmnetHelper] allocated attachment [id=default] [hostname=buildkit] [gateway=192.168.64.1] [address=192.168.64.6/24]
2025-07-25 12:48:26.708334+0800 0xf3d612   Info        0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `start` xpc handler [uuid=buildkit]
2025-07-25 12:48:26.777812+0800 0xf32176   Info        0x0                  61286  0    container-apiserver: [com.apple.container:APIServer] Handling container buildkit Start.
2025-07-25 12:48:31.806620+0800 0xf3d6d8   Info        0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `state` xpc handler [uuid=buildkit]
2025-07-25 12:48:31.813353+0800 0xf3d620   Info        0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `dial` xpc handler [uuid=buildkit]
2025-07-25 12:48:31.968950+0800 0xf3d80d   Info        0x0                  61292  0    container-core-images: [com.apple.container:ImagesHelper] ImagesService: pull(reference:platform:insecure:progressUpdate:) - ref: docker.io/library/ubuntu:20.04, platform: Optional(ContainerizationOCI.Platform(osVersion: nil, osFeatures: nil, variant: nil, _rawOS: "linux", _rawArch: "loong64")), insecure: false
2025-07-25 12:48:36.690965+0800 0xf3d620   Info        0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] init process exited with: 2 [uuid=buildkit]
2025-07-25 12:48:36.713834+0800 0xf3d6d8   Error       0x0                  26253  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] process deletion [error=internal error (13): unknown error processing request] [uuid=buildkit] [id=buildkit]
2025-07-25 12:48:36.719288+0800 0xf3d62c   Info        0x0                  61291  0    container-network-vmnet: [com.apple.container:NetworkVmnetHelper] released attachments [id=default] [hostname=buildkit]
2025-07-25 12:48:36.719630+0800 0xf3d5fe   Info        0x0                  61286  0    container-apiserver: [com.apple.container:APIServer] Handling container buildkit exit. Code 2
--------------------------------------------------------------------------------------------------------------------
Log      - Default:          0, Info:               14, Debug:             0, Error:          2, Fault:          0
Activity - Create:           0, Transition:          0, Actions:           0

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions