docker-composeでDjango+MySQLの環境を作りたい
docker-composeでDjango+MySQLの環境を作るため以下のDockerfileとdocker-composeを作成しました。
その後docker-compose up
を行うとdb側は立ち上がるのですがweb側はCommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.
とエラーが出てうまく立ち上がりません。
Djangoのsettings.pyでALLOWED_HOSTS = ['*']
としてもうまくいきませんでした。どうすればよろしいでしょうか。
Dockerfile
Dockerfile
1FROM python:3.9 2ENV PYTHONUNBUFFERED 1 3RUN mkdir /code 4WORKDIR /code 5ADD requirements.txt /code/ 6RUN pip install --upgrade pip 7RUN pip install -r requirements.txt 8ADD . /code/
docker-compose.yml
yaml
1version: '3' 2 3services: 4 db: 5 image: mysql 6 env_file: 7 - ./.vscode/.env 8 9 web: 10 build: . 11 command: python3 manage.py runserver 0.0.0.0:8000 12 volumes: 13 - .:/code 14 ports: 15 - "8000:8000" 16 depends_on: 17 - db
出力結果
db_1 | 2022-08-29 13:08:28+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started. db_1 | 2022-08-29 13:08:29+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' db_1 | 2022-08-29 13:08:29+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started. db_1 | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock' db_1 | 2022-08-29T13:08:29.805758Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead. db_1 | 2022-08-29T13:08:29.807234Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1 db_1 | 2022-08-29T13:08:29.815036Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. db_1 | 2022-08-29T13:08:30.333148Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. db_1 | 2022-08-29T13:08:30.467808Z 0 [System] [MY-010229] [Server] Starting XA crash recovery... db_1 | 2022-08-29T13:08:30.526247Z 0 [System] [MY-010232] [Server] XA crash recovery finished. db_1 | 2022-08-29T13:08:30.573352Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. db_1 | 2022-08-29T13:08:30.573407Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. db_1 | 2022-08-29T13:08:30.575009Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. db_1 | 2022-08-29T13:08:30.596703Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.30' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL. db_1 | 2022-08-29T13:08:30.597104Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock db_1 | 2022-08-29 13:17:16+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started. db_1 | 2022-08-29 13:17:16+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' db_1 | 2022-08-29 13:17:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started. db_1 | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock' db_1 | 2022-08-29T13:17:17.551676Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead. db_1 | 2022-08-29T13:17:17.553050Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1 db_1 | 2022-08-29T13:17:17.565245Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. db_1 | 2022-08-29T13:17:18.020379Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. db_1 | 2022-08-29T13:17:18.148925Z 0 [System] [MY-010229] [Server] Starting XA crash recovery... db_1 | 2022-08-29T13:17:18.157516Z 0 [System] [MY-010232] [Server] XA crash recovery finished. db_1 | 2022-08-29T13:17:18.207169Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. db_1 | 2022-08-29T13:17:18.207223Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. db_1 | 2022-08-29T13:17:18.209375Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. db_1 | 2022-08-29T13:17:18.230643Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.30' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL. db_1 | 2022-08-29T13:17:18.230649Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock web_1 | CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False. associating_game_web_1 exited with code 1

回答1件
あなたの回答
tips
プレビュー