Use docker to build reids to specify the configuration file. If you use docker run to set it, the configuration file redis.conf is valid:
docker run -d -ti \
-p 6379:6379 \
-v /home/docker/redis/conf/redis.conf:/etc/redis/redis.conf \
--restart always \
--name pos_redis \
redis:3.0.6 \
redis-server /etc/redis/redis.conf
However, the configuration file will not take effect in the way of docker-compose and dockerfile, and the default configuration file will be used automatically:
docker-compose.yml
version: "3"
services:
redis:
container_name: redis_service
build:
context: ./redis
dockerfile: Dockerfile
ports:
- "6379:6379"
volumes:
- /home/docker/redis/conf/redis.conf:/etc/redis/redis.conf
networks:
- "net1"
networks:
net1:
driver: bridge
dockerfile
FROM redis:3.0.6
ENV TIME_ZONE Asia/Shanghai
RUN usermod -u 1000 www-data \
&& apk add --no-cache tzdata \
&& echo "${TIME_ZONE}" > /etc/timezone \
&& ln -sf /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime \
&& redis-server /etc/redis/redis.conf
What is the difference between the two ways of running commands?
—————————————————————————
Supplement, use
ENTRYPOINT redis-server /etc/redis/redis.conf
Nor will it be implemented
I think there is something wrong with your Dockerfile.
apk
It is a package management command under Alpine Linux, but not under Alpineusermod
Instruction, so I guess you will report the error when your image is built, please check and put the error on it.