Unable to properly launch Web API using Docker (Compose)
As the title suggests, I am having issues in running my Web API through Docker. When I launch the project and want to open it using localhost it is unreachable.
My project structure:
Solution/
- docker-compose (default)
- docker-compose.override (default)
- API/
- dockerfile
The files:
Dockerfile:
Docker-compose:
3 Replies
docker-compose.override
I am running the project in .NET 9.
I even tried this project setup in a default weather forecast web api but still the same result.
Before I pulled my hair out of frustration I wenr to the basics and tried a simple GET method:
http://localhost:55720/weatherforecast
this returned the "hello world" I gave it.
Just to be sure, Are you trying to reach the http://localhost:8080 right? Without docker the port might be the 55720 but in your docker-compose you are telling that you are mapping for http 8080 your pc -> 8080 docker container, for https 8081 your pc -> 8081 docker container
Hey, I am sorry for my late reply. I have this discord muted and therefore did not managed to give you an answer.
In my setup above; yes I tried reaching localhost on
8080
. What I initially do in these kind of scenario's is to always map them equally. So it is always 8080:8080
& 8081:8081
. Since this did not work, I removed the mappings and went back to the basics, displaying a "hello world" through a GET
method.