特定 version の Redis server を Docker で構築する手順をご紹介します。
docker run --name redis2.8 -p 6379:6379 -d redis:2.8
docker logs redis2.8 -f
[1] 13 Feb 06:04:15.743 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.23 (00000000/0) 64 bit
.-`` .-```. ```\\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[1] 13 Feb 06:04:15.744 # Server started, Redis version 2.8.23
[1] 13 Feb 06:04:15.744 # 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.
[1] 13 Feb 06:04:15.744 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
[1] 13 Feb 06:04:15.744 * The server is now ready to accept connections on port 6379
最後に、redi-cli コマンド経由で docker 上に構築した redis-server へ接続確認して version を確認します。redis-cli コマンドは macOS に brew install redis で macOS にインストールしていたものを使います。
$ redis-cli
127.0.0.1:6379> INFO Server
# Server
redis_version:2.8.23
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:f02b64ca84a0dc52
redis_mode:standalone
os:Linux 4.9.125-linuxkit x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.9.2
process_id:1
run_id:b3a1f6c434378b687d2787247b00788853b647cc
tcp_port:6379
uptime_in_seconds:1153
uptime_in_days:0
hz:10
lru_clock:6535136
config_file:
redis の停止
docker stop redis2.8
redis の起動
docker start redis2.8
以上、たまに古い version の redis が使いたくなる現場からお送りしました。