Front not reaching back in docker-compose

20 views Asked by At

I have made a fullstack project, front with lit-element and back in spring boot. To deploy it I'm using Docker, made the images with a Dockerfile for eachone.

Then in the docker-compose I have the mongodb, the front and the back registered. The back is connecting succesfully to the mongodb, and I can make requests using Postman, but when the front makes requests to the back it throws this error to the console:

backend:8081/api-citas: Failed to load resource: net::ERR_NAME_NOT_RESOLVED

Im using fetch in my front project:

fetch("http://backend:8081/api-citas", requestOptions)

This is my docker-compose.yml

version: "3.9"
services:
  frontend:
    container_name: seguimiento-pacientes-full-frontend
    restart: always
    build: ./frontend
    ports: 
      - "8000:8000"
    networks:
      - backend_network

  backend:
    container_name: seguimiento-pacientes-full-backend
    restart: always
    build: ./back
    ports:
      - "8081:8081"
    networks:
      - backend_network
      
  mongo:
    container_name: mongo
    image: mongo
    restart: always
    expose:
      - "27017"
    volumes:
      - ./data:/data/seguimiento-citas
    ports:
      - "27017:27017"
    networks:
      - backend_network

networks:
  backend_network:
      driver: bridge
0

There are 0 answers