3
3

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 5 years have passed since last update.

docker・Rails・MySQLを使った時に出たUnknown MySQL server host 'localhost'

Posted at

この記事を進めていた時に発生したトラブルの解決メモ

問題

記事ではdocker-compose.ymlでmysqlのサービス名を「mysql」としていたが、個人的には「database」にしたかったのでdatabaseに変更したら

40f4d7b1ed8e76c03f15b367e6a9f887.png

が出るようになった。

解決法

docker-compose.ymlでappのlinksで指定するサービス名の後ろに:mysqlをつける

  links:
      - database

         ↓

  links:
      - database:mysql
3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?