Install Redis on Alpine based image in docker
Asked Answered
P

4

20

I am trying to install Redis on the golang:1.10.1-alpine3.7 image. I tried RUN apk add --no-cache redis, but when I tried to run the redis-cli command, I get an exit status 127, which means the given command in not found. I would like to know how I would be able to run the redis-cli command.

Pelagian answered 28/4, 2018 at 5:1 Comment(4)
I've just tried building the container like you instructed and when executing redis-cli the command seems to run just fine. Perhaps try using the fully qualified path of the command - /usr/bin/redis-cliShuping
Do you mind sharing a snippet of your code?Pelagian
Thanks i got it to work with /usr/bin/redis-cli.Pelagian
Cool, I'm adding that as an answer and would appreciate it if you could mark it as answered for anyone else who will seek an answer to this question.Shuping
S
19

Try using the fully qualified path of the command - /usr/bin/redis-cli.

Shuping answered 28/4, 2018 at 16:37 Comment(0)
R
37

To install it , use command as

apk --update add redis 
Reamer answered 24/9, 2020 at 8:7 Comment(0)
S
19

Try using the fully qualified path of the command - /usr/bin/redis-cli.

Shuping answered 28/4, 2018 at 16:37 Comment(0)
M
1

Specify the version of alpina in the Dockerfile

From alpina:3.8
RUN apk add --update redis
CMD [ "redis-server" ]

It works fine with version 3.8 and when it use version 3.19 it doesn't work. https://dl-cdn.alpinelinux.org/alpine/v3.19/main: temporary error (try again later)

Maleeny answered 10/12, 2023 at 23:21 Comment(0)
T
0

For Alpine I just copy the executable from a Redis image, like this:
This prevents from installing the 'whole' server suite when using apk install redis.

FROM alpine:3.20

COPY --from=redis:7-alpine3.20 /usr/local/bin/redis-cli /usr/local/bin/redis-cli

RUN redis-cli -h redis DEL "KEY*"
Tubing answered 13/7 at 22:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.