12 May 2020
version: '3' services: redis: image: redis:3.2.12 container_name: redis command: ["redis-server", "/usr/local/etc/redis/redis.conf"] volumes: - "/path/to/redis/data:/data" - "/path/to/redis/log:/var/log/redis" - "/path/to/reids/redis.conf:/usr/local/etc/redis/redis.conf"
bind 0.0.0.0,保证其他容器可以访问logfile /var/log/redis/redis_6379.log,日志路径和上面挂载的日志volumes/var/log/redis要统一daemonize no,不能后台daemon执行,docker需要command: ["redis-server", "/usr/local/etc/redis/redis.conf"]一直前台执行dir /data,需要和数据volumes/data保持一致requirepass redispass,redis官方容器默认是关闭了protechtion模式,所以推荐设定密码保证安全性redis 5.x镜像运行的用户是redis,其属主属组为999.1000
# root运行时 chown -R 999.1000 /path/to/dir/on/host/should/mounted/to/container # rootless运行时 podman unshare chown -R 999.1000 /path/to/dir/on/host/should/mounted/to/container