I have on question about docker,
I have my api called IdentityService for example with this configuration, launchsetting.json:
"IdentityService": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:5002"
}
My docker File of Identity -> EXPOSE 3000
Another project called, OcelotApiGateway
launchsetting.json:
"OcelotApiGateway": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:5001"
},
My docker File of Ocelot -> EXPOSE 3001
ocelot.json
{
"Routes": [
{
"UpstreamPathTemplate": "/api/Identity/{Id}",
"UpstreamHttpMethod": [ "GET" ],
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5002
}
],
"DownstreamPathTemplate": "/api/Identity/{Id}",
"GatewayOptions": {
"Timeout": 3000,
"BaseUrl": "http://localhost:4592"
}
}
],
"GlobalConfiguration": {}
}
When I run this two project without docker it works, https://localhost:5001/api/Identity/54325
But when I run this project with docker-compose it doesn't works, my docker-compose.yml
services:
ocelotapigateway:
container_name: api-gateway
image: ${DOCKER_REGISTRY-}ocelotapigateway
build:
context: .
dockerfile: OcelotApiGateway/Dockerfile
ports:
- 4592:3001
identityservice:
container_name: identityservice
image: ${DOCKER_REGISTRY-}identityservice
build:
context: .
dockerfile: IdentityService/Dockerfile
ports:
- 4593:3000
And I don't find the error, anyone can help me? Maybe it's for the https... I don't know.. Thanks a lot to all community!
I try to call https://localhost:4592/api/Identity/641ee2820974a1c9b854c56e and see the same results because I use docker to redirect the information.
Finally I saw that my configuration wasn't correct,
For example; IdentityService Configuration;
Launch Settings JSON;
"applicationUrl": "http://localhost:5117"
DOCKERFILE EXPOSE 80
Ocelot Configuration;
"applicationUrl": "http://localhost:5075"
DOCKERFILE EXPOSE 80
ocelot.json;
{
"Routes": [
{
"UpstreamPathTemplate": "/api/Identity/{Id}",
"UpstreamHttpMethod": [ "GET" ],
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "identityservice",
"Port": 80
}
],
"DownstreamPathTemplate": "/api/Identity/{Id}"
}
],
"GlobalConfiguration": {
"BaseUrl": "http://localhost:3001"
}
}
Finally my docker compose,
networks:
backend:
services:
ocelotapigateway:
container_name: api-gateway
image: ${DOCKER_REGISTRY-}ocelotapigateway
build:
context: .
dockerfile: OcelotApiGateway/Dockerfile
ports:
- 3001:80
networks:
- backend
identityservice:
container_name: identityservice
image: ${DOCKER_REGISTRY-}identityservice
build:
context: .
dockerfile: IdentityService/Dockerfile
networks:
- backend