I am using docker compose with multi container setup. I have an angular app, deployed on nginx and exposed to port 80. On second container, I am hosting .note core API, this service is returning a string.
In angular, I am calling URL http://localhost/api/values
Take a look at my attached docker compose.yml file. With my current set-up, when I hit localhost at port 81 in my local browser, I get the desired result.
But, in Angular app , rather than using “localhost”, I wanted to use “webapi”(http://webapi/api/values), I tried all sorts of options but I am not getting desired output. So far, I tried using hostname, container_name, aliases, etc
I would appreciate if you can point out my mistake here and help me to get desire output. Also, I would appreciate if you can suggest best option in case we run multiple instances on .net service.
Once this issues is solved, I am planning to deploy it on Azure, would I be needing any additional settings/configurations?
Here is my yml file
Thanks in advance.
version: '3.7'
services:
web:
build: hello
container_name: web
hostname: web
image: jayforu/hello
networks:
backend:
#aliases:
# - web
# ipv4_address: 172.16.238.01
ports:
- 81:80
webapi:
build: HelloApi
container_name: webapi
hostname: webapi
image: jayforu/helloapi
networks:
backend:
#aliases:
# - webapi
#ipv4_address: 172.16.238.02
ports:
- 80:80
networks:
backend:
# ipam:
driver: bridge
# config:
# - subnet: "172.16.238.0/24"
