15👍
Add network, link and depends_on configuration in docker compose file.
example:
services:
db:
build: .
container_name: db
networks:
- djangonetwork
web:
build: .
depends_on:
- db
links:
- db:db
networks:
- djangonetwork
networks:
djangonetwork:
driver: bridge
11👍
To the others experiencing this.
The following command (which removes all unused containers, networks, images, and optionally, volumes) solve my problem:
docker system prune
See docker document for more information
- [Django]-Different initial data for each form in a Django formset
- [Django]-Django URL Redirect
- [Django]-Django: "TypeError: [] is not JSON serializable" Why?
4👍
Answering my question, this was a stupid one…
My manage.py was selecting only the base.py settings file, and was not taking into account the staging.py settings file. So it was breaking in the CLI and was not breaking inside the app.
- [Django]-How to start doing TDD in a django project?
- [Django]-Celery unable to use redis
- [Django]-Django 1.7 throws django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet
1👍
In the “django” part of your docker-compose.yml under “depends_on” section try adding links: - db:db
after it, or even replace the depends_on: db with that.
I’ll bet if you typed in docker logs (container name)
you’d see it’s obviously having trouble working out where “db” points to.
I think they’re looking to end support for links in docker-compose in new iterations at least I read that somewhere..
- [Django]-How to set environment variables in PyCharm?
- [Django]-Django filter the model on ManyToMany count?
- [Django]-How do I use pagination with Django class based generic ListViews?
1👍
FWIW, for anyone using Podman, this issue could be due to the containers not being able to find each other within the network. This post helped me solve the problem
https://github.com/containers/podman/issues/9292.
Essentially, you also need to make sure that the network’s dns_enable
is set to true.
- [Django]-Django 1.11 Annotating a Subquery Aggregate
- [Django]-Setting default value for Foreign Key attribute in Django
- [Django]-Django Admin Form for Many to many relationship
0👍
If you use docker (compose), you can try:
- Terminal:
docker compose down --remove-orphans
- Terminal:
docker compose up -d
The problem seems to occure because of stale containers/networks which are interfering with the DNS resolution. By using docker system prune
or a simple down and up you remove/restart those containers. By using --remove-orphans
you also take care of containers not started by the docker-compose.yml
- [Django]-How can I correctly set DJANGO_SETTINGS_MODULE for my Django project (I am using virtualenv)?
- [Django]-MySQL "incorrect string value" error when save unicode string in Django
- [Django]-What is the best approach to change primary keys in an existing Django app?
-2👍
click on this link to get your answer or add command: bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
in docker-compose.yaml
.I hope this will work for you. It worked for me
- [Django]-Count frequency of values in pandas DataFrame column
- [Django]-Django serializer Imagefield to get full URL
- [Django]-How to repeat a "block" in a django template