2016-09-22 18 views
2

私はコンテナを使って開発しており、ドッキング用のコンポを使って持ち上げています。 時々私はdocker-compose downを実行し、コンテナを再構築します。時間のほとんどは、私はこのエラーを取得PG :: ConnectionBad "/var/run/postgresql/.s.PGSQL.5432"を持つRails、Postgres、およびDocker?

PG::ConnectionBad (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"? 
): 

Railsは全体のコンテナが再びを再構築されている場合Postgresが、そこにされていない文句を言っている理由私は得ることはありません。また、エラーはちょうど私が何か他の停止、再起動、または再構築することなく、しばらくして消える。 私はこのような厄介な問題から正確に逃れるために、コンテナで開発に移った。

これはPostgresのサービスで私のdocker-compose.yml

version: '2' 
services: 
    users: 
    build: 
     context: '.' 
    links: 
     - postgres 
     - redis 
    volumes: 
    - ".:/app/users/" 
    working_dir: /app/users 
    command: [rails, server, -p, "3000", -b, 0.0.0.0] 
    ports: 
    - "3000:3000" 

    postgres: 
    image: postgres:9.5 
    environment: 
     POSTGRES_DB: somedb 
     POSTGRES_USER: someuser 
     POSTGRES_PASSWORD: somepass 

    redis: 
    image: redis:latest 
    command: redis-server 
    ports: 
     - "6379:6379" 
    volumes: 
     - "redis:/var/lib/redis/data" 

volumes: 
    redis: 

database.yml

development: 
    <<: *default 
    database: somedb 
    user: someuser 
    password: somepass 
    host: postgres 
    port: 5432 

私は足りない余分な構成の内容であるか、それは、ユーザーのコンテナに関連していますか?

+0

あなたはこれまでに解決しましたか? – creimers

+0

@creimersは正確ではありません。受け入れられた答えをご覧ください。 – Sebastialonso

答えて

0

を参照してくださいドッキングウィンドウ-compose.ymlユーザーに追加し、悲しいことに、問題が離れたときに行ってきましたdown容器を築き、再び建てる。

1

version: '2' 
services: 
    users: 
    environment: 
     DATABASE_URL:postgres://user:[email protected]:5432/datex_dev?pool=5&encoding=utf-8 
    .... 

はdatabase.ymlの

development: 
    <<: *default 
    url: <%= ENV['DATABASE_URL'] %> 
    ... 

に追加記録のためにDocker - PG::ConnectionBad

関連する問題