I created Dockerfile to ruby from official docker-compose website. I used docker compose to integrate this with Postgres. When docker-compose up, then PostgreSQL starts but I cannot connect to this. The main problem is in ruby database config because I can't change to listen to another host and set the default user. I don't know how to connect these two containers without changing the ruby database config.
Dockerfile
FROM ruby:2.3.4
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /myapp
WORKDIR /myapp
ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
ADD . /myapp
Docker-compose
version: '3'
services:
db:
image: postgres:9.6
ports:
- "5432:5432"
web:
build: .
ports:
- "4000:4000"
depends_on:
- db
Ruby database.yml
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: project_development
If i run inside web conatiner "bundle exec rake db:create I get error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I don't know what env set that will connect together.