So I am running a django node and a regular python script using docker-compose. The python script regularly asks django backend for data. However, when I docker-compose up I get this error:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=8080): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3d6e45dc10>: Failed to establish a new connection: [Errno 111] Connection refused'))
Here is my docker-compose.yaml:
version: "3"
services:
backend:
command: >
sh -c "python3 manage.py wait_for_db &&
python3 manage.py migrate &&
python3 manage.py runserver 0.0.0.0:8080"
build:
context: ./backend
dockerfile: Dockerfile
volumes:
- ./backend:/backend
ports:
- "8080:8080"
monitor:
command: >
sh -c "python3 main.py"
build:
context: ./monitor
dockerfile: Dockerfile
volumes:
- ./monitor:/monitor
ports:
- "8082:8082"
from monitor I do:
response = requests.get(url = 'http://0.0.0.0:8080/')
What is a correct way to communicate between nodes in docker?
P.S Cors origins are allowed in django
url='http://backend:8080/'