Ubuntu Docker容器中的Redis未附加自定义Redis.conf文件

Ubuntu Docker容器中的Redis未附加自定义Redis.conf文件,ubuntu,docker,redis,docker-compose,Ubuntu,Docker,Redis,Docker Compose,我很难让redis在docker容器中启动。当我跑的时候 docker-compose up 我看到了输出 Starting redis_redis_1 Attaching to redis_redis_1 redis_redis_1 exited with code 0 之后,我可以跑步了 docker ps -a 看 这是我的docker-compose.yml redis: image: redis command: redis-server /usr/local/

我很难让redis在docker容器中启动。当我跑的时候

docker-compose up
我看到了输出

Starting redis_redis_1
Attaching to redis_redis_1
redis_redis_1 exited with code 0
之后,我可以跑步了

docker ps -a

这是我的docker-compose.yml

redis:
    image: redis
    command: redis-server /usr/local/etc/redis/redis.conf
    ports:
      - "6379:6379"
    volumes:
      - /mnt/xvdb/redis/:/usr/local/etc/redis/
      - ./redis/redis.conf:/usr/local/etc/redis/redis.conf
这是我得到的详细输出:

ubuntu@ip-10-0-1-172:~/redis$ docker-compose --verbose up --build
compose.config.config.find: Using configuration files: ./docker-compose.yml
docker.auth.auth.find_config_file: Trying paths: ['/home/ubuntu/.docker/config.json', '/home/ubuntu/.dockercfg']
docker.auth.auth.find_config_file: No config file found
compose.cli.command.get_client: docker-compose version 1.9.0, build 2585387
docker-py version: 1.10.6
CPython version: 2.7.6
OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
compose.cli.command.get_client: Docker base_url: http+docker://localunixsocket
compose.cli.command.get_client: Docker version: KernelVersion=3.13.0-48-generic, Os=linux, BuildTime=2016-12-12T23:50:16.747144109+00:00, ApiVersion=1.24, Version=1.12.4, GitCommit=1564f02, Arch=amd64, GoVersion=go1.6.4
compose.cli.verbose_proxy.proxy_callable: docker info <- ()
compose.cli.verbose_proxy.proxy_callable: docker info -> {u'Architecture': u'x86_64',
 u'BridgeNfIp6tables': True,
 u'BridgeNfIptables': True,
 u'CPUSet': True,
 u'CPUShares': True,
 u'CgroupDriver': u'cgroupfs',
 u'ClusterAdvertise': u'',
 u'ClusterStore': u'',
 u'Containers': 1,
 u'ContainersPaused': 0,
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False, filters={u'label': [u'com.docker.compose.project=redis', u'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={u'label': [u'com.docker.compose.project=redis', u'com.docker.compose.service=redis', u'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- (u'e8617d77bbdcdd36be35a130ea7afd764a8777d0b2d4df0700a5bf708ed63810')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {u'AppArmorProfile': u'',
 u'Args': [u'redis-server', u'/usr/local/etc/redis/redis.conf'],
 u'Config': {u'AttachStderr': False,
             u'AttachStdin': False,
             u'AttachStdout': False,
             u'Cmd': [u'redis-server', u'/usr/local/etc/redis/redis.conf'],
             u'Domainname': u'',
             u'Entrypoint': [u'docker-entrypoint.sh'],
             u'Env': [u'affinity:container==3379fa24f2ec222251f97b39f194b629841b79e85707d62ee9a922becdb0cc40',
                      u'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('redis')
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {u'Architecture': u'amd64',
 u'Author': u'',
 u'Comment': u'',
 u'Config': {u'ArgsEscaped': True,
             u'AttachStderr': False,
             u'AttachStdin': False,
             u'AttachStdout': False,
             u'Cmd': [u'redis-server'],
             u'Domainname': u'',
             u'Entrypoint': [u'docker-entrypoint.sh'],
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={u'label': [u'com.docker.compose.project=redis', u'com.docker.compose.service=redis', u'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('redis')
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {u'Architecture': u'amd64',
 u'Author': u'',
 u'Comment': u'',
 u'Config': {u'ArgsEscaped': True,
             u'AttachStderr': False,
             u'AttachStdin': False,
             u'AttachStdout': False,
             u'Cmd': [u'redis-server'],
             u'Domainname': u'',
             u'Entrypoint': [u'docker-entrypoint.sh'],
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- (u'e8617d77bbdcdd36be35a130ea7afd764a8777d0b2d4df0700a5bf708ed63810')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {u'AppArmorProfile': u'',
 u'Args': [u'redis-server', u'/usr/local/etc/redis/redis.conf'],
 u'Config': {u'AttachStderr': False,
             u'AttachStdin': False,
             u'AttachStdout': False,
             u'Cmd': [u'redis-server', u'/usr/local/etc/redis/redis.conf'],
             u'Domainname': u'',
             u'Entrypoint': [u'docker-entrypoint.sh'],
             u'Env': [u'affinity:container==3379fa24f2ec222251f97b39f194b629841b79e85707d62ee9a922becdb0cc40',
                      u'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
compose.parallel.feed_queue: Pending: set([<Service: redis>])
compose.parallel.feed_queue: Starting producer thread for <Service: redis>
compose.service.start_container_if_stopped: Starting redis_redis_1
compose.cli.verbose_proxy.proxy_callable: docker attach <- (u'e8617d77bbdcdd36be35a130ea7afd764a8777d0b2d4df0700a5bf708ed63810', stderr=True, stream=True, stdout=True)
compose.cli.verbose_proxy.proxy_callable: docker attach -> <generator object frames_iter at 0x7fd372c02c80>
compose.cli.verbose_proxy.proxy_callable: docker start <- (u'e8617d77bbdcdd36be35a130ea7afd764a8777d0b2d4df0700a5bf708ed63810')
compose.parallel.feed_queue: Pending: set([])
compose.cli.verbose_proxy.proxy_callable: docker start -> None
compose.parallel.parallel_execute_iter: Finished processing: <Service: redis>
compose.parallel.feed_queue: Pending: set([])
Attaching to redis_redis_1
compose.cli.verbose_proxy.proxy_callable: docker events <- (decode=True, filters={u'label': [u'com.docker.compose.project=redis', u'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker events -> <generator object _stream_helper at 0x7fd372c02e60>
compose.cli.verbose_proxy.proxy_callable: docker wait <- (u'e8617d77bbdcdd36be35a130ea7afd764a8777d0b2d4df0700a5bf708ed63810')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- (u'e8617d77bbdcdd36be35a130ea7afd764a8777d0b2d4df0700a5bf708ed63810')
compose.cli.verbose_proxy.proxy_callable: docker wait -> 0
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {u'AppArmorProfile': u'',
 u'Args': [u'redis-server', u'/usr/local/etc/redis/redis.conf'],
 u'Config': {u'AttachStderr': False,
             u'AttachStdin': False,
             u'AttachStdout': False,
             u'Cmd': [u'redis-server', u'/usr/local/etc/redis/redis.conf'],
             u'Domainname': u'',
             u'Entrypoint': [u'docker-entrypoint.sh'],
             u'Env': [u'affinity:container==3379fa24f2ec222251f97b39f194b629841b79e85707d62ee9a922becdb0cc40',
                      u'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
redis_redis_1 exited with code 0
什么也没给我

docker logs redis_redis_1


任何帮助都值得赞赏

因此,我能够让Redis使用我认为是默认的配置文件运行。因为这里第一行的警告

redis_1  | 1:C 19 Dec 12:30:29.397 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1  |                 _._                                                  
redis_1  |            _.-``__ ''-._                                             
redis_1  |       _.-``    `.  `_.  ''-._           Redis 3.2.6 (00000000/0) 64 bit
redis_1  |   .-`` .-```.  ```\/    _.,_ ''-._                                   
redis_1  |  (    '      ,       .-`  | `,    )     Running in standalone mode
redis_1  |  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
redis_1  |  |    `-._   `._    /     _.-'    |     PID: 1
redis_1  |   `-._    `-._  `-./  _.-'    _.-'                                   
redis_1  |  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
redis_1  |  |    `-._`-._        _.-'_.-'    |           http://redis.io        
redis_1  |   `-._    `-._`-.__.-'_.-'    _.-'                                   
redis_1  |  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
redis_1  |  |    `-._`-._        _.-'_.-'    |                                  
redis_1  |   `-._    `-._`-.__.-'_.-'    _.-'                                   
redis_1  |       `-._    `-.__.-'    _.-'                                       
redis_1  |           `-._        _.-'                                           
redis_1  |               `-.__.-'                                               
redis_1  | 
redis_1  | 1:M 19 Dec 12:30:29.399 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1  | 1:M 19 Dec 12:30:29.399 # Server started, Redis version 3.2.6
redis_1  | 1:M 19 Dec 12:30:29.400 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1  | 1:M 19 Dec 12:30:29.400 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1  | 1:M 19 Dec 12:30:29.400 * DB loaded from disk: 0.000 seconds
redis_1  | 1:M 19 Dec 12:30:29.400 * The server is now ready to accept connections on port 6379
这就是我在最初的问题中找到redis.conf文件的原因,在那里我覆盖了默认命令

之后,我可以检查默认配置文件中的实际内容

docker exec db00a03fd187 cat /usr/local/etc/redis/redis.conf
要查找我的自定义配置文件,正在使用该文件

因为我将配置文件映射到默认目录,所以我想我得到了输出。所以,没有问题

这是我的docker-compose.yml文件,我最终得到了:

redis:
    image: redis
    ports:
      - "6379:6379"
    volumes:
      - ./redis/redis.conf:/usr/local/etc/redis/redis.conf
      - /mnt/xvdb/redis:/usr/local/etc/redis

因此,我能够让Redis运行我认为是默认配置文件的东西。因为这里第一行的警告

redis_1  | 1:C 19 Dec 12:30:29.397 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1  |                 _._                                                  
redis_1  |            _.-``__ ''-._                                             
redis_1  |       _.-``    `.  `_.  ''-._           Redis 3.2.6 (00000000/0) 64 bit
redis_1  |   .-`` .-```.  ```\/    _.,_ ''-._                                   
redis_1  |  (    '      ,       .-`  | `,    )     Running in standalone mode
redis_1  |  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
redis_1  |  |    `-._   `._    /     _.-'    |     PID: 1
redis_1  |   `-._    `-._  `-./  _.-'    _.-'                                   
redis_1  |  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
redis_1  |  |    `-._`-._        _.-'_.-'    |           http://redis.io        
redis_1  |   `-._    `-._`-.__.-'_.-'    _.-'                                   
redis_1  |  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
redis_1  |  |    `-._`-._        _.-'_.-'    |                                  
redis_1  |   `-._    `-._`-.__.-'_.-'    _.-'                                   
redis_1  |       `-._    `-.__.-'    _.-'                                       
redis_1  |           `-._        _.-'                                           
redis_1  |               `-.__.-'                                               
redis_1  | 
redis_1  | 1:M 19 Dec 12:30:29.399 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1  | 1:M 19 Dec 12:30:29.399 # Server started, Redis version 3.2.6
redis_1  | 1:M 19 Dec 12:30:29.400 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1  | 1:M 19 Dec 12:30:29.400 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1  | 1:M 19 Dec 12:30:29.400 * DB loaded from disk: 0.000 seconds
redis_1  | 1:M 19 Dec 12:30:29.400 * The server is now ready to accept connections on port 6379
这就是我在最初的问题中找到redis.conf文件的原因,在那里我覆盖了默认命令

之后,我可以检查默认配置文件中的实际内容

docker exec db00a03fd187 cat /usr/local/etc/redis/redis.conf
要查找我的自定义配置文件,正在使用该文件

因为我将配置文件映射到默认目录,所以我想我得到了输出。所以,没有问题

这是我的docker-compose.yml文件,我最终得到了:

redis:
    image: redis
    ports:
      - "6379:6379"
    volumes:
      - ./redis/redis.conf:/usr/local/etc/redis/redis.conf
      - /mnt/xvdb/redis:/usr/local/etc/redis

当你制作
docker logs redis\u redis\u 1
时,你会得到什么?@pascallemerer Nothing。。。更新了问题(见最后几行)@smur89是否重新启动了docker服务?我不想这么说,但我有过这样的错误,重启docker经常会修复它们。不鼓励自信,但如果它起作用……只是为了排除它是问题的根源,请尝试删除第二个挂载('./redis/redis.conf:/usr/local/etc/redis/redis.conf'),并将您的redis.conf直接放入/mnt/xvdb/redis/。尝试了这两种建议,但是得到同样的结果当你制作<代码>docker logs redis_redis_1时你会得到什么?@Pascallemerer Nothing。。。更新了问题(见最后几行)@smur89是否重新启动了docker服务?我不想这么说,但我有过这样的错误,重启docker经常会修复它们。不鼓励自信,但如果它起作用……只是为了排除它是问题的根源,请尝试删除第二个挂载('./redis/redis.conf:/usr/local/etc/redis/redis.conf'),并将您的redis.conf直接放入/mnt/xvdb/redis/。尝试了这两种建议,但得到了相同的结果