Не удается подключиться к mysql docker [duplicate]
когда я запускаю команду 'python manage.py makemigrations'
ошибка :
C:\Users\pc\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\core\management\commands\makemigrations.py:160:
RuntimeWarning: Got an error checking a consistent migration history performed for database connection
'default': (2003, "Can't connect to MySQL server on 'mysql' ([Errno 11001] getaddrinfo failed)")
warnings.warn
(
No changes detected
я использую docker и запустил mysql-container (dev-mysql)
Я пытаюсь запустить django как бэкэнд с базой данных mysql в контейнере docker локально и натыкаюсь на ошибку. Я не знаю, почему я получаю эту проблему, я перепробовал так много решений
my settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'tp',
'USER': 'root',
'PASSWORD': '125',
'HOST': 'mysql',
'PORT': 3306,
}
}
docker-compose
version: '3.8'
services:
mysql:
image: mysql:8.0
container_name: dev-mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 125
MYSQL_DATABASE: tp
ports:
- "3307:3306"
volumes:
- mysql_data:/var/lib/mysql # Use the named volume
networks:
- my_bridge
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 30s
timeout: 10s
retries: 5
backend-app:
image: backend:latest # Use the already built image
container_name: backend-app
restart: always
ports:
- "8001:8000"
depends_on:
mysql:
condition: service_healthy
networks:
- my_bridge
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/admin/login/?next=/admin/ || exit 1"]
interval: 30s
timeout: 10s
retries: 5
frontend-app:
image: frontend-app:latest # Use the already built image
container_name: frontend-app
restart: always
ports:
- "81:80"
depends_on:
mysql:
condition: service_healthy
backend-app:
condition: service_healthy
networks:
- my_bridge
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost || exit 1"]
interval: 30s
timeout: 10s
retries: 3
networks:
my_bridge:
external: true
volumes:
mysql_data:
external:
name: d211ff04cd14c527f6883cbed641a6ee85c3f54c5638ab7544cd1577c8989074
ошибка при выполнении python manage.py makemigrations