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
This solves a bunch of problems all ready:
Setting environment variables gets us up faster.
Need to do some sysctl magic to get things working.
Mounting external volume allows us to persist Redis data.
Bring it up:
docker-compose up redis
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.
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
Now bring it up:
docker-compose up -d redis
Top comments (0)