0

I'm new to docker and working on dockerising an existing RoR app. Here's my docker-compose.yml file:-

version: '3.8'
services:
  web:
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    depends_on:
      - postgres
    ports:
      - '3000:3000'
  postgres:
    image: postgres:latest

On running docker-compose up, I'm able to map to the rails server but getting the error in the title, looks like postgres is not connecting to the container. I don't know what to do, I just want to my machine to the rails app in docker conatiner.

maya_nk99
  • 502
  • 3
  • 5
  • In your `database.yml` file, you need to set the database host name to the name of the database container, `postgres`. `localhost` refers to the Rails application container itself. – David Maze Jun 01 '22 at 16:48
  • You change `postgres: image: postgres:latest` to `db: image: postgres container_name: myapp_db env_file: - .db.env ports: - "5432:5432"` – LihnNguyen Jun 04 '22 at 04:22

0 Answers0