1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

DockerのPostgreSQLに接続できない

Posted at

事象・事前切り分け

  • Docker上に構築したPostgreSQLにパスワードが合っていないとエラーが出る
  • psqlコマンドでDocker環境内からのアクセスには問題ない事を確認した

解決

Docker上に構築したPostgreSQLデータベースへの接続(A5SQL)が上手く行かず

当初パスワードが違うとのエラーでDocker側のパスワード設定を確認するもパスワードは合っている

原因を調べたところ接続側(Windows)にもPostgreSQLが動いておりポートが同じ(5432)で干渉していた

Windows側のPostgreSQL Serviceを止めて対応で解決できそうだが、職場PCの為不可

docker-compose.ymlを以下の様に変更して、Dockerイメージを再作成

version: '3.1'
services:
  pg:
    image: postgres:latest
    ports:
      - "5433:5432" ←"接続からの接続ポート:DockerのPostgreSQLポート"なので左のポートを変更
    enviroment:
      - xxxx

docker-compose up

無事起動

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?