After below changes, I am able to access individual API and also via ocelot gateway using docker.
- Removed ports definition from docker-compose.yml
- In ocleot.json included service name as host and port as 8080
- Exposed only 8080 as port from API's docker file
Final ocelot.json
{
"Routes": [
{
"DownstreamPathTemplate": "/api/products",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "productservice",
"Port": 8080
}
],
"UpstreamPathTemplate": "/products",
"UpstreamHttpMethod": [ "Get" ]
},
]
}