use docker to build reids to specify the configuration file. If you use docker run to set it, the configuration file redis.conf is effective:
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
but with docker-compose plus dockerfile, the configuration file will not take effect, and the default configuration file is automatically used:
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?
-
add, use
ENTRYPOINT redis-server / etc/redis/redis.conf
also do not execute