master-db という Docker コンテナー内の MySQL インスタンスに接続する Quart アプリケーション (ページャー) をテストしようとしていますが、数回再試行した後、hypercorn エラーが発生します。
pager | Traceback (most recent call last):
pager | File "/usr/local/bin/hypercorn", line 8, in <module>
pager | sys.exit(main())
pager | File "/usr/local/lib/python3.9/site-packages/hypercorn/__main__.py", line 267, in main
pager | run(config)
pager | File "/usr/local/lib/python3.9/site-packages/hypercorn/run.py", line 34, in run
pager | worker_func(config)
pager | File "/usr/local/lib/python3.9/site-packages/hypercorn/asyncio/run.py", line 187, in asyncio_worker
pager | _run(
pager | File "/usr/local/lib/python3.9/site-packages/hypercorn/asyncio/run.py", line 229, in _run
pager | loop.run_until_complete(main(shutdown_trigger=shutdown_trigger))
pager | File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
pager | return future.result()
pager | File "/usr/local/lib/python3.9/site-packages/hypercorn/asyncio/run.py", line 69, in worker_serve
pager | sockets = config.create_sockets()
pager | File "/usr/local/lib/python3.9/site-packages/hypercorn/config.py", line 177, in create_sockets
pager | insecure_sockets = self._create_sockets(self.bind)
pager | File "/usr/local/lib/python3.9/site-packages/hypercorn/config.py", line 240, in _create_sockets
pager | sock.bind(binding)
pager | socket.gaierror: [Errno -2] Name does not resolve
pager exited with code 1
コードはローカルで動作し、完全にテストされていますが、どこが間違っているのかわかりません:(
docker-compose ファイルは次のとおりです。
version: "3.8"
networks:
localdev:
driver: bridge
services:
master-db:
image: mysql:8.0
container_name: master-db
command: --default-authentication-plugin=mysql_native_password
restart: always
ports:
- "4000:3306"
environment:
MYSQL_ROOT_PASSWORD: password_for_stackoverflow
volumes:
- ./database/docker:/etc/mysql/conf.d
networks:
- localdev
pager:
build:
context: .
dockerfile: Dockerfile.pager
container_name: pager
ports:
- "2020:2020"
networks:
- localdev
depends_on:
- master-db
Docker.pager:
FROM python:3-alpine
RUN pip install --upgrade pip
RUN pip install hypercorn
RUN pip install mysql-connector
RUN pip install quart
COPY src/common /app/common
COPY src/pager /app/pager
WORKDIR /app
CMD ["hypercorn", "pager:app", "--bind", "'0.0.0.0:2020'"]