I’m trying to connect to an express database on sql server accesible throughout 192.168.0.130:1433 on local network from Docker Django container.
I’m on a Mac and from local host i have ping
$ ping 192.168.0.130
64 bytes from 192.168.0.130: icmp_seq=0 ttl=128 time=5.796 ms
64 bytes from 192.168.0.130: icmp_seq=1 ttl=128 time=2.234 ms
But inside docker container get timeout error.
docker-compose.yml:
version: '3.7'
services:
...
django:
container_name: djangonoguero_django_ctnr
build:
context: .
dockerfile: Dockerfile-django
restart: unless-stopped
env_file: ./project/project/settings/.env
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./project:/djangonoguero
depends_on:
- postgres
ports:
- 8000:8000
networks:
- djangonoguero-ntwk
networks:
djangonoguero-ntwk:
driver: bridge
Anybody could help me please ?
Thanks in advance.
2
Answers
Reset fabric default values from Docker solved the problem.
For example, you have postgres container:
Then, in your django project settings, you should write:
Be careful, this is example settings! Best practice is to store this data in
.env
file!