docker redis - 无法打开日志文件:没有那个文件或目录

docker redis -Can't open the log file: No such file or directory

我的 OS 是:ubuntu:15.10

我想使用官方docker-hub redis,但是遇到了问题。

我的docker-compose.yml

version: '2'
services:

  redis:
    image: redis
    ports:
      - "6379:6379"
    volumes:
      -  ~/dbdata/redis_conf/redis.conf:/usr/local/etc/redis/redis.conf
    volumes_from:
      -  redisdata
    environment:
      - REDIS_PASSWORD: 29c4181fb842b5f24a3103dbd2ba17accb1f7e3c8f19868955401ab921
    command: redis-server /usr/local/etc/redis/redis.conf

redisdata:
    image: redis
    volumes:
      - /home/keryhu/dbdata/redisdb:/data
    command: --break-redis

我将默认的 redis.conf 复制到“~/dbdata/redis_conf/redis.conf”目录。只需将 "requirepass" 修改为“29c4181fb842b5f24a3103dbd2ba17accb1f7e3c8f19868955401ab921”

当我启动容器时,遇到错误 -

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 103
>>> 'logfile /var/log/redis/redis-server.log'
Can't open the log file: No such file or directory

可以帮我吗?

如我所见here,未指定日志文件,所有日志都输出到标准输出。我不会改变这种行为,因为那样 docker 将自己管理日志,这是标准且更灵活的方式。

如果您想将日志输出重定向到某个地方,我建议您使用作曲家的 logging directive

我碰巧遇到了这个问题too.Finally,我在我的主机上动了redis.log,然后把它挂载在docker上。 step1: touch /yourself's location/redis-server.log docker run -d -v /yourself's location/redis-server.log:/var/log/redis/redis-server.log -v /your/redis.config:/usr/local/etc/redis/redis.conf --name myredis redis redis-server /usr/local/etc/redis/redis.conf 如果你想挂载一个文件或目录,它们必须首先存在,否则会出现权限被拒绝或空目录。