DEV Community

Frederick Ollinger
Frederick Ollinger

Posted on

Install Redis 6.2 Inside Centos 7 Docker Container

You'd think this would be easy, but like everything else there are some tricks.

Here's what I did for my docker-compose.

NOTE: That this is not the latest Redis but 6.2 is my current requirements so here we go.

version: '3.7'
services:
  redis:
    image: redis:6.2
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    sysctls:
      - net.core.somaxconn=511
    volumes:
      - $PWD/redis-data:/var/lib/redis
Enter fullscreen mode Exit fullscreen mode

This solves a bunch of problems all ready:

  1. Setting environment variables gets us up faster.

  2. Need to do some sysctl magic to get things working.

  3. Mounting external volume allows us to persist Redis data.

Bring it up:

docker-compose up redis
Enter fullscreen mode Exit fullscreen mode

Of course, there's all ready issues:

Starting containers-2891_redis_1 ... done
Attaching to containers-2891_redis_1
redis_1  | 1:C 20 Jan 2023 01:50:54.485 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1  | 1:C 20 Jan 2023 01:50:54.485 # Redis version=6.2.10, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1  | 1:C 20 Jan 2023 01:50:54.485 # 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  | 1:M 20 Jan 2023 01:50:54.485 * monotonic clock: POSIX clock_gettime
redis_1  | 1:M 20 Jan 2023 01:50:54.486 * Running mode=standalone, port=6379.
redis_1  | 1:M 20 Jan 2023 01:50:54.486 # Server initialized
redis_1  | 1:M 20 Jan 2023 01:50:54.487 # Can't handle RDB format version 10
redis_1  | 1:M 20 Jan 2023 01:50:54.487 # Fatal error loading the DB: Invalid argument. Exiting.
Enter fullscreen mode Exit fullscreen mode

Starting the redis-server explicitly seems to work:

version: '3.7'
services:
  redis:
    image: redis:6.2
    command: ["redis-server", "--appendonly", "yes"]
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    sysctls:
      - net.core.somaxconn=511
    volumes:
      - $PWD/redis-data:/var/lib/redis
Enter fullscreen mode Exit fullscreen mode

Now bring it up:

docker-compose up -d redis
Enter fullscreen mode Exit fullscreen mode

Top comments (0)