docker-compose up myapp.sample.api
Creating network "myapp_frontend" with the default driver
myapp-sample-mssql-cnr is up-to-date
Creating myapp-sample-api-cnr ... done
Attaching to myapp-sample-api-cnr
myapp-sample-api-cnr | warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
myapp-sample-api-cnr | No XML encryptor configured. Key {daa358c7-8c64-4e3c-90ea-06f48de12ad4} may be persisted to storage in unencrypted form.
myapp-sample-api-cnr | Hosting environment: Development
myapp-sample-api-cnr | Content root path: /app
myapp-sample-api-cnr | Now listening on: http://[::]:5000
myapp-sample-api-cnr | Application started. Press Ctrl+C to shut down.
Problem here is that I cannot open my web api app on this specified port
http://localhost:5000
returns Could not get any response from a postman
Locally I am able to open this app through visual studio debug.
docker-compose.yml
version: '3.4'
networks:
frontend:
backend:
services:
myapi.sample.api:
build:
context: .
dockerfile: MyApi.Sample.API/Dockerfile
image: myappsampleapi-img
container_name: myapp-sample-api-cnr
ports:
- "5000:80"
networks:
- backend
- frontend
depends_on:
- mssqlserver
mssqlserver:
image: "microsoft/mssql-server-linux:latest"
ports:
- "1445:1433"
container_name: myapp-sample-mssql-cnr
networks:
- backend
Dockerfile
FROM microsoft/dotnet:2.2-aspnetcore-runtime as base
WORKDIR /app
EXPOSE 80
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ...
...
ENTRYPOINT ["dotnet", "MyApi.Sample.API.dll"]
I am not able to get any log output from the api container
docker logs -f myapp-sample-api-cnr
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {82dd75ea-8302-4859-a3e5-78eedf856e34} may be persisted to storage in unencrypted form.
Hosting environment: Development
Content root path: /app
Now listening on: http://[::]:5000
Application started. Press Ctrl+C to shut down.
Edit: I tried to change Dockerfile to expose port 5000 instead of 80
FROM microsoft/dotnet:2.2-aspnetcore-runtime as base
WORKDIR /app
EXPOSE 5000
and on docker ps -a I'm getting
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
964724837d13 myappsampleapi-img "dotnet MyApi.S…" 45 seconds ago Up 43 seconds 5000/tcp, 0.0.0.0:5000->80/tcp, 0.0.0.0:32788->80/tcp myapp-sample-api-cnr
Still having the same problem, cannot get response from api on localhost:5000