Не удается подключиться к серверу mysql - docker
Я хочу запустить python manage.py makemigrations
я использую docker и запустил mysql-container
Я пытаюсь запустить python backend с базой данных mysql в контейнере docker локально и натыкаюсь на ошибку : i dont why im getting this problem, i tried so many solutions
"Can't connect to MySQL server on 'mysql' ([Errno 11001] getaddrinfo failed)")
warnings.warn(
No changes detected
my settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'tp',
'USER': 'root',
'PASSWORD': '125',
'HOST': 'mysql-container', # ou 'localhost' si vous utilisez un port local
'PORT': '3306',
}
}
мой docker-composer
services:
mysql:
image: mysql:latest
container_name: mysql-container
hostname: 'mysql'
restart: always
environment:
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: 125
MYSQL_DATABASE: tp
ports:
- "3306: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:
build:
context: ./backend # Assure-toi que le chemin est correct
dockerfile: Dockerfile # Assure-toi que le Dockerfile est présent
image: backend:latest # Use the already built image
container_name: backend-app
restart: always
ports:
- "8000: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:
build:
context: ./frontend
dockerfile: Dockerfile
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
я хочу подключиться к mysql