2
1

CircleCI でデータベース接続のHOST設定はどうすれば良いのか ( 127.0.0.1 / localhost で接続エラー )

Posted at

エラー例 - Rails + Postgress の場合

rails db:create の実行でDBに接続できずにエラーが発生する

could not connect to server: Connection refused
        Is the server running on host "127.0.0.1" and accepting
        TCP/IP connections on port ****?

データベース接続のホストには何を指定すれば良いのか

解決

circleCIの設定で以下のように Dockerコンテナに付けた名前がそのままホスト名として使えるようだ

以下の例だとCircleCIの他のdockerコンテナからホスト名として example-db を参照できるようになる

.circleci/config.yml
jobs:
  test:
    docker:
      - image: <DB用のイメージ>
        name: "example-db"

ただしDBと他で jobs を分割してしまうと動かなかった

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

2
1
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
2
1