Build/push amd64 docker image from M1 mac and pull/exec on root-less singularity machine

Posted on April 30, 2023 by  ‐ 1 min read

Build/push amd64 docker image from M1 mac and pull/exec on root-less singularity machine

Build/push amd64 image from arm64/M1 mac machine

buildx

docker buildx create --use --name mybuilder
docker buildx inspect --bootstrap

build

docker buildx build --platform linux/amd64 -t your-dockerhub-username/example:latest . --push

Replace --push with --load for local use.

test run

docker buildx build --platform linux/amd64 -t your-dockerhub-username/example:latest . --load
docker run --platform linux/amd64 --rm -it your-dockerhub-username/example:latest /bin/bash

Pull/exec on singularity machine

pull

singularity pull your-singularity-image.sif docker://your-dockerhub-username/example:latest

exec

singularity exec -B $(pwd):$(pwd) your-singularity-image.sif