How to run Redis docker container for Mac Silicon?
Asked Answered
P

2

6

Looking at the Redis image, https://hub.docker.com/_/redis, it says that it supports Arm64. However when I run the image on a Mac M1, it shows an AMD64 warning badge (i.e. poor performance due to Rosetta emulation)

How do I specify the ARM64 version of redis?

Here's the Dockerfile:

FROM redis:alpine
WORKDIR /usr/app
COPY conf/redis.conf /usr/local/etc/redis/redis.conf
EXPOSE 6379

Here's the warning: enter image description here

I'm running this on an M1 Mac.

Phylloquinone answered 12/7, 2022 at 18:58 Comment(2)
How did you build the Dockerfile? Is the image you're running public?Consequential
@Consequential The image is not public. The Dockerfile is built using docker-compose (if I've understood your question correctly).Phylloquinone
C
8

You should use arm64v8/redis instead of the default. So, replace:

FROM redis:alpine

For:

FROM arm64v8/redis:alpine

More info here: https://hub.docker.com/r/arm64v8/redis

Alternatively, you can use the --platform arg or use the TARGETPLATFORM, as explained here:

https://nielscautaerts.xyz/making-dockerfiles-architecture-independent.html

Camelopardalis answered 12/7, 2022 at 19:23 Comment(1)
This is a separately built image, though, not the official one. There are different support modelsQuarterly
C
0
FROM redis:alpine
WORKDIR /usr/app
COPY conf/redis.conf /usr/local/etc/redis/redis.conf
EXPOSE 6379

The Dockerfile is built using docker-compose

You haven't deployed the multi-platform redis image. You've deployed your own image built from that, and docker-compose build doesn't create multi-platform images. If you build it locally on your M1, it should be an ARM64 image. If you want to build multi-platform images, then I'd switch to building with:

docker buildx build --platform=linux/amd64,linux/arm64 -t gitlab.netbuilder.io:5050/... .

You can inspect the image with commands like (replacing redis:alpine with your own image):

docker buildx imagetools inspect redis:alpine
Consequential answered 13/7, 2022 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.