Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

353
Vistas
Docker container does not communicate with others in same docker network(bridge)

I'm trying to set the environment for web server on amazon web server. I want to use django, react, nginx and they are running on each docker container.

Belows are the command for running docker container.

sudo docker run --name django-server
  -it -d -p "8000:8000"
  --volume=$(pwd)/trello-copy-django-src:/backend/trello-copy
  django-server

sudo docker run --name nginx-server
  -d -p "80:80"
  --volumes-from react-server
  nginx-server

I did not specified a custom docker network bridge and I checked that they are on same default bridge by typing $ docker inspect bridge.

[{
  "Name": "bridge",
  ...,
  "Containers": {
    "...": { "Name": "django-server", ... },
    "...": { "Name": "react-server", ... },
    "...": { "Name": "nginx-server", ... },
  }
}]

So, I expected the react code down below works. But it worked only at my laptop, which has exactly same docker structure of aws.

...
const res = await fetch('http://127.0.0.1:8000/api/');
...

Failed to load resource: net::ERR_CONNECTION_REFUSED 127.0.0.1:8000/api/:1

What am I doing wrong?


These are codes in my settings.py file of django.

CORS_ORIGIN_ALLOW_ALL=True # only for dev
CORS_ALLOW_CREDENTIALS=True # only for dev
CORS_ORIGIN_WHITELIST = (
    'http://localhost',
    'http://localhost:3000',
)

The CORS message was App.js:10 Fetch API cannot load django-server:8000/api/. URL scheme must be "http" or "https" for CORS request..

I think it's different issue, and then django and CORS are not really problem... am I right?


I found that the 'localhost' of ajax await fetch('http://127.0.0.1:8000/api/'); means client side(browser) indeed.

Do I have to use server's public IP in there?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can't call by 127.0.0.1. Instead, you need to use name of the running container. Like this:

const res = await fetch('django-server:8000/api/');
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda