Change:
Describe the bug It seems generates images with the wrong architecture set. ( began setting these values, but the values before were also wrong) To Reproduce Compared to the current version of : If you actually run the image on arm, Docker complains. Expected behavior Architectures embedded in the image configuration should match those generated by Docker. Additional context The warning message printed by Docker if the running platform doesn't match the image's platform. The operating system, architecture, and variant are determined by and . (If the image's architecture is "arm" and the variant is empty, as it almost always is, it is normalized to "v7", see ) Notify maintainers Metadata system: host os: multi-user?: sandbox: version: channels(root): channels(terin): nixpkgs: Maintainer information:
The specification is a bit loose, but the examples given all follow and . If we take a look at the specification, the fields should be and . Every officiall and semi-official image I've looked at, included the pre-multiarch manifest "legacy" images referenced at follow this pattern.

Discussion:
docker-edge = handleTestOn ["x86_64-linux"] ./docker-edge.nix {}; docker-registry = handleTest ./docker-registry.nix {}; docker-tools = handleTestOn ["x86_64-linux"] ./docker-tools.nix {}; <ins> docker-tools-cross = handleTestOn ["x86_64-linux" "aarch64-linux"] ./docker-tools-cross.nix {}; </ins> docker-tools-overlay = handleTestOn ["x86_64-linux"] ./docker-tools-overlay.nix {}; documize = handleTest ./documize.nix {}; dokuwiki = handleTest ./dokuwiki.nix {};

<ins> # Not everyone has a suitable remote builder set up, so the cross-compilation # tests that _include_ running the result are separate. That way, most people # can run the majority of the test suite without the extra setup. import ./make-test-python.nix ({ pkgs, ... }: let remoteSystem = if pkgs.system == "aarch64-linux" then "x86_64-linux" else "aarch64-linux"; remoteCrossPkgs = import ../.. /*nixpkgs*/ { # NOTE: This is the machine that runs the build -  local from the #       'perspective' of the build script. localSystem = remoteSystem; # NOTE: Since this file can't control where the test will be _run_ we don't #       cross-compile _to_ a different system but _from_ a different system crossSystem = pkgs.system; }; hello1 = remoteCrossPkgs.dockerTools.buildImage { name = "hello1"; tag = "latest"; contents = remoteCrossPkgs.hello; }; hello2 = remoteCrossPkgs.dockerTools.buildLayeredImage { name = "hello2"; tag = "latest"; contents = remoteCrossPkgs.hello; }; in { name = "docker-tools"; meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ roberth ]; }; nodes = { docker = { ... }: { virtualisation = { diskSize = 2048; docker.enable = true; }; }; }; testScript = '' docker.wait_for_unit("sockets.target") with subtest("Ensure cross compiled buildImage image can run."): docker.succeed( "docker load --input='${hello1}'" ) assert "Hello, world!" in docker.succeed( "docker run --rm ${hello1.imageName} hello", ) docker.succeed( "docker rmi ${hello1.imageName}", ) with subtest("Ensure cross compiled buildLayeredImage image can run."): docker.succeed( "docker load --input='${hello2}'" ) assert "Hello, world!" in docker.succeed( "docker run --rm ${hello2.imageName} hello", ) docker.succeed( "docker rmi ${hello2.imageName}", ) ''; }) </ins>

"docker inspect ${pkgs.dockerTools.examples.cross.imageName} " + "| ${pkgs.jq}/bin/jq -r .[].Architecture" ).strip() <del> == "${if pkgs.system == "aarch64-linux" then "amd64" else "arm64v8"}" </del> <ins> == "${if pkgs.system == "aarch64-linux" then "amd64" else "arm64"}" </ins> ) ''; })

done; ''; <del> # Map nixpkgs architecture to Docker notation # Reference: https://github.com/docker-library/official-images#architectures-other-than-amd64 getArch = nixSystem: { aarch64-linux = "arm64v8"; armv7l-linux = "arm32v7"; x86_64-linux = "amd64"; powerpc64le-linux = "ppc64le"; i686-linux = "i386"; }.${nixSystem} or "Can't map Nix system ${nixSystem} to Docker architecture notation. Please check that your input and your requested build are correct or update the mapping in Nixpkgs."; </del> <ins> # The OCI Image specification recommends that configurations use values listed # in the Go Language document for GOARCH. # Reference: https://github.com/opencontainers/image-spec/blob/master/config.md#properties # For the mapping from Nixpkgs system parameters to GOARCH, we can reuse the # mapping from the go package. defaultArch = go.GOARCH; </ins> in rec {

, imageDigest , sha256 , os ? "linux" <del> , arch ? getArch system </del> <ins> , arch ? defaultArch </ins> # This is used to set name to the pulled image , finalImageName ? imageName

baseJson = let pure = writeText "${baseName}-config.json" (builtins.toJSON { inherit created config; <del> architecture = getArch system; </del> <ins> architecture = defaultArch; </ins> os = "linux"; }); impure = runCommand "${baseName}-config.json"

streamScript = writePython3 "stream" {} ./stream_layered_image.py; baseJson = writeText "${name}-base.json" (builtins.toJSON { inherit config; <del> architecture = getArch system; </del> <ins> architecture = defaultArch; </ins> os = "linux"; });