DB can be available, but connection takes a while to be ready, if django runs before that without any on hold commands, django will fail to start
Ideal solution will be added the following command to docker-compose.yml
command: >
sh -c "python manage.py <wait_for_db_command>&&
python manage.py migrate &&
python manage.py runserver 0.0.0.0:8000"
Need also to create a django custom command <wait_for_db_command>
https://docs.djangoproject.com/en/4.0/howto/custom-management-commands/
No comments:
Post a Comment