Open1

エラー議事録

tama8021tama8021

【Docker】 docker-compose up でデーターベースだけが起動後すぐ落ちる

エラー文

Running via Spring preloader in process 20
could not translate host name "db" to address: Name or service not known
Couldn't create 'myapp_development' database. Please check your configuration.
rake aborted!
ActiveRecord::ConnectionNotEstablished: could not translate host name "db" to address: Name or service not known

解決策

docker-compose.yml
(略)
### PostgreSQL ###########################################
    db:
      image: postgres
      volumes:
        # ここの「/data」を削除する
        #- ./tmp/db:/var/lib/postgresql/data
        - ./tmp/db:/var/lib/postgresql
(略)

原因

わからなかったです、、

参考

https://mrkmyki.com/docker-for-windowsとlaradocでpostgresのコンテナが起動できない場合の対