2

I have a Dockerfile that pulls FROM hivemq/hivemq-ce. This works well on "standard" platforms but not on the Raspberry Pi. So I built the image for arm64 myself directly on the RasPi following the tutorial in the official HiveMQ repo and pushed it to my private docker registry. The Dockerfile works well on RasPi if I change the FROM line to FROM my-private-registry/hivemq-ce.

So now I have images that work on different platforms in different sources. But how can I make my Dockerfile work on all platforms? Is there any way to pull from different sources for different architectures?

Fred
  • 1,103
  • 2
  • 14
  • 35

2 Answers2

2

As outlined here docker supports multiple cpu architectures and will select the correct image for the correct platform. So you could build a non arm64 image for frederikheld/hivemq-ce and push it to the same location without affecting the arm64 image.

You should be able to run docker manifest inspect frederikheld/hivemq-ce to see the available architectures for a given image.

Don't Panic
  • 13,965
  • 5
  • 32
  • 51
maxm
  • 3,412
  • 1
  • 19
  • 27
  • But the images for all other platforms are already available at hivemq/hivemq-ce. So I need to push the same images to my own location just to have all architectures in one place? Seems to violate the DRY principle... Is there no other way, something like "if arch==arm64: FROM location1, else: FROM location2" – Fred Dec 07 '20 at 01:01
  • 1
    `hivemq/hivemq-ce` doesn’t seem to have arm images built. If you had push access you could just push your arm image to that repository. It might make sense to have an if statement like that (and you could make it happen yourself with a build arg), but I think docker expects repositories to build for multiple architectures so that you don’t have this problem. You might want to request that hivemq build for arm64 – maxm Dec 07 '20 at 01:53
2

I went with this approach:

start.sh:

...
if [ "$(uname -m)" = "aarch64" ]; then
    docker-compose -f docker-compose.aarch64.yml up -d --build --force-recreate
else
    docker-compose up -d --build --force-recreate
fi
...

This requires one standard docker-compose.yml and additional docker-compose.<architecture>.yml for each architecture that has different needs.

It's not great, but it works in my environment.

I'm still open for better solutions though!

Fred
  • 1,103
  • 2
  • 14
  • 35