私はコンテナを使って開発しており、ドッキング用のコンポを使って持ち上げています。 時々私は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
私は足りない余分な構成の内容であるか、それは、ユーザーのコンテナに関連していますか?
あなたはこれまでに解決しましたか? – creimers
@creimersは正確ではありません。受け入れられた答えをご覧ください。 – Sebastialonso