Last active
March 16, 2022 19:35
-
-
Save hohonuuli/f94942e280819095ef1eeae2460fe097 to your computer and use it in GitHub Desktop.
Example build script for docker containers on M1/Arm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
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.