I have an application that is divided in 2 parts: Frontend and Backend. My Frontend is a React JS application and my backend is a Java Spring boot application. This project is running in Docker, and there's 3 containers: frontend, backend and db (database). My problem is that I can't make my front and send any request to my backend container. Below is my Docker configuration files:
Docker-compose:
version: "3" services: db: image: postgres:9.6 container_name: db ports: - "5433:5432" environment: - POSTGRES_PASSWORD=123 - POSTGRES_USER=postgres - POSTGRES_DB=test backend: build: context: ./backend dockerfile: Dockerfile container_name: backend ports: - "8085:8085" depends_on: - db frontend: container_name: frontend build: context: ./frontend dockerfile: Dockerfile expose: - "80" ports: - "80:80" links: - backend depends_on: - backend Dockerfile frontend:
# Stage 0, "build-stage", based on Node.js, to build and compile the frontend FROM node:8.12.0 as build-stage WORKDIR /app COPY package*.json /app/ RUN yarn COPY ./ /app/ RUN yarn run build # Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx FROM nginx RUN rm -rf /usr/share/nginx/html/* COPY --from=build-stage /app/build/ /usr/share/nginx/html # Copy the default nginx.conf provided by tiangolo/node-frontend COPY --from=build-stage /app/nginx.conf /etc/nginx/conf.d/default.conf Dockerfile backend:
FROM openjdk:8 ADD /build/libs/reurb-sj-13-11-19.jar reurb-sj-13-11-19.jar EXPOSE 8085 ENTRYPOINT ["java", "-jar", "reurb-sj-13-11-19.jar", "--app.db.host= Is Frontend I've tried to send requests to these Ip's:
- localhost:8085
- 172.18.0.3:8085
- 172.18.0.3
- 0.0.0.0:8085
When I try to send a request from Frontend, it "starts" and waits for about 10 seconds, then it returns with an error. The weird part is that my request doesn't return with any status.
PS.: I've read all internet and everyone said to put EXPOSE, PORTS and the LINKS (inside docker-compose), I've tried but still doesn't work.