version: "3.0"
services:
backend:
build: ./backend
ports:
- "3600:8000"
depends_on:
- mysql
redis:
image: redis
mysql:
image: mysql:5.6
environment:
- MYSQL_DATABASE=django-app
- MYSQL_ROOT_PASSWORD=password
This is my docker-compose.yml
#!/bin/sh
cd src
rm *.sqlite3
python manage.py makemigrations
python manage.py migrate
daphne -b 0.0.0.0 -p 8000 literature.asgi:application
This is my docker entrypoint for the backend.
But whenever I do docker-compose up
. It fails to migrate the database succesfully and I get the error saying "Can't connect to mysql". But if I restart just the django-app container then it works fine. All migrations are finished and django-admin works.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django-app',
'USER': 'root',
'PASSWORD': 'password',
'HOST': 'mysql',
'PORT': '3306',
}
}
It works fine if I use SQLite instead.