I have a somewhat specific, Swift-based problem.
It seems that none of the official Swift images on Dockerhub support the M1, and instead the only seemingly reliable arm64 Swift images are found at swiftarm/swift. This means that manifest querying will always fail for an M1 for something like FROM swift:5.5.2. Additionally, trying to get around this with --platform=x86_64 the particular project I'm trying to run fails to compile due to an error with the Swift compiler in QEMU.
Is there a way to do something like

IF platform == arm64 FROM swiftarm/swift
ELSE FROM swift:5.5.2

or should I just build and push my own multiplatform image

2 Answers 2


---build-arg Set build-time variables it is possible to build with arch parameter depending on this arch is whether host arch or docker image arch.


It would be hacky, but you could sed it in with a wrapper script.

#! /usr/bin/env bash

platform=$(uname -p)

if [[ $platform == "arm64" ]]; then
    sed -i 's/FROM swift\:5\.5\.2/FROM swiftarm\/swift/' Dockerfile

docker build ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.