Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Can't connect to redis using Rails 7, Docker and hotwire-livereload

$
0
0

I'm trying to get gem hotwire-livereload working with my rails project. I'm trying to dockerise everything before I start to work. The hotwire-livereload gem uses redis to work.

Here is my Dockerfile

FROM ruby:3.2.2WORKDIR /appRUN apt-get update -qq && apt-get install -y \    nodejsCOPY Gemfile* ./RUN gem install bundler && bundle install --jobs 4 --retry 3COPY . .EXPOSE 3000CMD ["rails", "server", "-b", "0.0.0.0"]

And here is my docker-compose file

version: '3'services:  app:    build:      context: .      dockerfile: Dockerfile.dev    ports:      - '3000:3000'    volumes:      - .:/app    depends_on:      - db      - redis    env_file:      - .env  db:    image: postgres    environment:      POSTGRES_USER: ${DATABASE_USERNAME}      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}    ports:      - '${DATABASE_PORT}:5432'    volumes:      - db-data:/var/lib/postgresql/data  redis:    image: redis    ports:      - '6379:6379'    volumes:      - redis-data:/datavolumes:  db-data:  redis-data:

When I try to run the docker, my app is starting, I can load the homepage, and then it's instantly crashing with the following error :Error connecting to Redis on localhost:6379 (Errno::EADDRNOTAVAIL) (Redis::CannotConnectError)

I tried differents docker-compose configurations but didn't manage to find one working


Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>