I want to enable password for my Redis container in minikube
. So, I enabled requirepass
in redis.conf
. Then, I generated the Docker image with this configuration file using the following Dockerfile
.
FROM redis
COPY --chown=redis:redis redis.conf /usr/local/etc/redis/redis.conf
CMD ["redis-server", "/usr/local/etc/redis/redis.conf"]
Then, I launch a pod with this image using the following Deployment
YAML.
kind: Deployment
apiVersion: apps/v1
metadata:
name: cache
labels:
run: cache
spec:
replicas: 1
selector:
matchLabels:
run: cache
template:
metadata:
labels:
run: cache
spec:
containers:
- name: cache
image: redis
envFrom:
- configMapRef:
name: redis-cfgmap
resources:
limits:
memory: "256Mi"
cpu: "200m"
imagePullPolicy: Never
restartPolicy: Always
terminationGracePeriodSeconds: 30
Note, I am doing a docker build -t redis:latest
from a shell that has run eval $(minikube docker-env)
. Also, imagePullPolicy
is set to Never
so that the image is pulled from local Dokcer registry.
While the pod does come up, the logs mention that, the specified configuration file is not used.
6:C 27 Feb 2020 04:06:08.568 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
6:C 27 Feb 2020 04:06:08.568 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=6, just started
6:C 27 Feb 2020 04:06:08.568 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
6:M 27 Feb 2020 04:06:08.570 * Running mode=standalone, port=6379.
6:M 27 Feb 2020 04:06:08.570 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
6:M 27 Feb 2020 04:06:08.570 # Server initialized
6:M 27 Feb 2020 04:06:08.571 * Ready to accept connections
What is missing?
Just a little more explanation for whom might want to read it.
It looks like for some reason the image you were building - instead of overwriting existing image as it should - wasn't doing it and you were stuck with redis:latest
official image, not the one you just built.
When approaching this problem and trying to build the image I had the same issue as you and managed to solve it running docker system prune
, but after that I didn't manage to replicate it one more time so its hard for me to say what was the real cause of it.
Anyway I am glad that it worked for you.