Good morning everyone, i'm quite new to Docker and i'm trying to learn it with a simple project. Currently i have a client container and a service container, with their respective Dockerfiles as follow:
#Server Dockerfile
FROM openjdk:17
COPY target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/app.jar"]
#Client Dockerfile
FROM node:16-alpine
WORKDIR './src/app'
COPY package.json .
RUN npm install
RUN apk update
RUN apk add curl
COPY . .
EXPOSE 4200
CMD ["npm","start"]
#docker-compose
version: "0.0.0"
services:
client:
build: Ecommerce-client/
container_name: ecommerce-client
ports: #per essere chiamato dall'esterno
- 4200:4200
networks:
- ecommerce
server:
build: Ecommerce-products/
container_name: ecommerce-product
networks:
- ecommerce
expose: #la porta che espone all'interno della nostra network
- "8080"
networks:
ecommerce:
driver: bridge
The simple client just show a list of objects sent by the service, in localhost everything works just fine but then when i try with the docker-compose file, i get the error net::ERR_NAME_NOT_RESOLVED.
In my ts client i have one simple call to the service as follow:
this.httpClient.get<any>("http://ecommerce-product:8080/products").subscribe(data => {
this.products = data;
});
I tryed to create a bash inside my client and make a call with curl and everything works, but when i open it in my browser it doesn't work. What could be my problem? Thank you!
http://ecommerce-productresolves to? Please also show thedocker-compose.ymlports:for the backend and connect tolocalhostand the backend's published port.