# config/initializers/redis.rb
Redis.current = Redis.new(:url => ENV['REDIS_URL'])
web:
build:
context: .
environment:
REDIS_URL: redis://redis:6379
.
.
.
depends_on:
- redis
redis:
image: redis:3.2.4
ports:
- "6379:6379"
.
.
.
$ docker-compose run web rails console
Redis.current.set "foo", "bar"
=> "OK"
Redis.current.get "foo"
=> "bar"