Skip to content

Instantly share code, notes, and snippets.

@hohonuuli
Last active March 16, 2022 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hohonuuli/f94942e280819095ef1eeae2460fe097 to your computer and use it in GitHub Desktop.
Save hohonuuli/f94942e280819095ef1eeae2460fe097 to your computer and use it in GitHub Desktop.
Example build script for docker containers on M1/Arm
#!/usr/bin/env bash
echo "--- Building vars-kb-server (reminder: run docker login first!!)"
VCS_REF=`git tag | sort -V | tail -1`
docker buildx build --platform linux/amd64,linux/arm64 \
-t mbari/vars-kb-server:${VCS_REF} \
-t mbari/vars-kb-server:latest \
--push . \
&& docker pull mbari/vars-kb-server:latest
@hohonuuli
Copy link
Author

hohonuuli commented Mar 2, 2022

You don't need to tag the image with the platform. It seems that this is stored in the image's metadata and docker will pull the appropriate image for your computers architecture. On M1, if no arm image is available, it will attempt to run the amd64 image via rosetta. The downsides to that are that it's much slower AND I've found that amd64 images tend to crash a lot on arm.

@hohonuuli
Copy link
Author

hohonuuli commented Mar 2, 2022

If you're just testing locally, you can run this instead:

docker buildx build \
        --platform linux/arm64 \
        --load \
        -t mbari/vars-kb-server:latest .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment