下記のQiitaを参考にして、Django、MySQLの開発環境をDockerで構築しています。
https://qiita.com/kenkono/items/6221ad12670d1ae8b1dd
マイグレーションをするところで、下記エラーが発生してしまいます。
docker-compose run python ./manage.py makemigrations
$ docker-compose run python ./manage.py makemigrations Starting djangotest2_db_1 ... Starting djangotest2_db_1 ... done Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 920, in connect **kwargs) File "/usr/local/lib/python3.6/socket.py", line 704, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -3] Temporary failure in name resolution During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection self.connect() File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect self.connection = self.get_new_connection(conn_params) File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 236, in get_new_connection return Database.connect(**conn_params) File "/usr/local/lib/python3.6/site-packages/pymysql/__init__.py", line 90, in Connect return Connection(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 699, in __init__ self.connect() File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 967, in connect raise exc pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'db' ([Errno -3] Temporary failure in name resolution)") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 332, in execute self.check() File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 364, in check include_deployment_checks=include_deployment_checks, File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 57, in _run_checks issues = run_checks(tags=[Tags.database]) File "/usr/local/lib/python3.6/site-packages/django/core/checks/registry.py", line 73, in run_checks new_errors = check(app_configs=app_configs) File "/usr/local/lib/python3.6/site-packages/django/core/checks/database.py", line 10, in check_database_backends issues.extend(conn.validation.check(**kwargs)) File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 9, in check issues.extend(self._check_sql_mode(**kwargs)) File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 13, in _check_sql_mode with self.connection.cursor() as cursor: File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 255, in cursor return self._cursor() File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 232, in _cursor self.ensure_connection() File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection self.connect() File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection self.connect() File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect self.connection = self.get_new_connection(conn_params) File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 236, in get_new_connection return Database.connect(**conn_params) File "/usr/local/lib/python3.6/site-packages/pymysql/__init__.py", line 90, in Connect return Connection(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 699, in __init__ self.connect() File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 967, in connect raise exc django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 'db' ([Errno -3] Temporary failure in name resolution)")
バージョンが関係しているのか、設定が足りていないのか不明です。
よろしくお願いします。
■環境
Windows - WSL Ubuntu 18.04
Macでも試したところ同じ現象でした。
回答1件
あなたの回答
tips
プレビュー