I have an Angular app running in a NginX Docker container.
The Angular app can make a REST call to another container (Spring Boot API Docker) using localhost as server.
server: string = 'localhost';
return this.httpClient.post<MyClass[]>('http://' + this.server + ':6060/files-data/list-files', request);
But REST call fails when using Docker service name instead.
server: string = 'files-service';
return this.httpClient.post<MyClass[]>('http://' + this.server + ':8080/files-data/list-files', request);
*using 8080 port this time as trying to resolve docker service name
Error in UI console:
net::ERR_NAME_NOT_RESOLVED
Using default NginXimage with default nginx.conf.
nginx-files-ui:
image: nginx:latest
container_name: nginx-files-ui
volumes:
- ./files-ui/dist/html:/usr/share/nginx/html
ports:
- 99:80
Containers all run on same Docker network.
networks:
default:
external:
name: files-net
Modified nginx.conf to include resolver but no joy.
resolver 127.0.0.11 valid=30s;
Any idea why I cannot make a REST call using Docker service name ?
EDIT
It seems Angular code running in browser is not able to resolve service names.