Redis: `Cannot assign requested address` with default config in Ubuntu 18.04 docker image

Created on 22 Jun 2018  路  3Comments  路  Source: redis/redis

Hi there, I'm not pretty sure that is bug in redis and not in Ubuntu image or Docker itself, but I feel like I should start from this bug tracker

I have a very simple dockerfile:

FROM ubuntu:16.04
RUN apt-get update && apt-get -y install redis-server
CMD service redis-server start && \ 
    redis-server --version && \
    tail -f /var/log/redis/redis-server.log

It's working fine in ubuntu 16.04:

$ docker run -it e1f
Starting redis-server: redis-server.
Redis server v=3.0.6 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=687a2a319020fa42
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

20:M 22 Jun 09:31:04.781 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
20:M 22 Jun 09:31:04.781 # Server started, Redis version 3.0.6
20:M 22 Jun 09:31:04.781 # 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.
20:M 22 Jun 09:31:04.781 # 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.
20:M 22 Jun 09:31:04.781 * The server is now ready to accept connections on port 6379

But if I change base image to ubuntu 18.04

FROM ubuntu:18.04
RUN apt-get update && apt-get -y install redis-server
CMD service redis-server start && \ 
    redis-server --version && \
    tail -f /var/log/redis/redis-server.log

I get:

$ docker run -it 87d
Starting redis-server: redis-server.
Redis server v=4.0.9 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=1bc80a08306a3efd
16:C 22 Jun 09:32:51.116 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
16:C 22 Jun 09:32:51.116 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=16, just started
16:C 22 Jun 09:32:51.116 # Configuration loaded
17:M 22 Jun 09:32:51.117 # Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address

and redis server fails to start

Most helpful comment

Found workaround - disable IPv6 for redis by
sed -i "s/bind .*/bind 127.0.0.1/g" /etc/redis/redis.conf

All 3 comments

Found workaround - disable IPv6 for redis by
sed -i "s/bind .*/bind 127.0.0.1/g" /etc/redis/redis.conf

Dupe of #3894 I think.

Now fixed in Redis 5 and unstable. Just merged into 4.0 branch as well. Closing.

Was this page helpful?
0 / 5 - 0 ratings