Dockerizing dotnet
Can anyone help me with dockerizing .NET backend? I have used Golang for backend before and dockerizing that was very simple, but it seems very complicated in .NET....
17 Replies
Have you tried something yet ? or are you facing any specific problem ?
Visual Studio can generate the Dockerfile and compose for you if needed
it's simple
yes
I have a specific question
When i run docker compose up i get the server running in the container and the volume mounting works. But when i try to send a curl request to the server i get the following:
curl: (56) Recv failure: Connection reset by peer
I have tried to troubleshoot this but i cant find the problem...
Here is my docker file:
Here is my docker compose file:
after restoring the packages, you need to build the project and publish it. Here's an example
these two short videos might help
https://www.youtube.com/watch?v=yQtgY4VG3kM
https://www.youtube.com/watch?v=JiJeZOHx0ow
Amichai Mantinband
YouTube
Dockerize Your .NET Application in 5 Minutes!
All videos in this playlist: https://www.youtube.com/playlist?list=PLzYkqgWkHPKCw7zPNV3xnN1JjtglUzB2W
In today's video we'll see how simple it is to dockerize a .NET application.
We'll create a Dockerfile with 3 stages for building, publishing, and running our web application in just a few minutes.
Join us on discord: https://www.patreon.com/...
Amichai Mantinband
YouTube
Getting started with Docker Compose
All videos in this playlist: https://www.youtube.com/playlist?list=PLzYkqgWkHPKCw7zPNV3xnN1JjtglUzB2W
In today's video, we'll see how simple it is to set up Docker Compose and use it to configure both our .NET application and a postgres database simply by running "docker compose up --build"
Join us on discord: https://www.patreon.com/amantinb...
yup that's not a complete dockerfile, look at what kauan posted
Its a development dockerfile
Not prod
still that's not complete
Also i run dotnet run in entrypoint.sh
if the goal is to run the application, it's not happening in your case
you just pulled the dependencies
Yes but in the docker compose there is defined entrypoint
which executes a shell script
dotnet run
.sure but it doesn't have any source code
yes it does because of the volume mounting in the docker compose
i see
yeah The thing is:
i can send curl request from within the docker shell but not form outside of the docker shell
So the code works fine, the backend is launched and runnung but i cannot send requests to the backend from outside of the container...
alr
i think we had a similar problem
it was something to do with the apache config
because a proxy was used
I remember there was also something to do with container networks or whatever
we could send requests to a docker container directly but not via port mapping
I wasn't the one solving it so I don't know the solution
or the exact problem
hmmm, then i suspect port mapping as the problem. I will try to send http rq to the backend from the frontend. They are in the same container in development
So if it is any mapping or CORS i should get an error
I got it to work!!! @everyone
The problem was that in docker i cant use localhost(127.0.0.0) i switched to 0.0.0.0 and now its working
Thanks for the effort
Ya'll made this very difficult. Building container images is built into the .NET Publishing SDK.
In VS you can right click and hit publish container. From the CLI you can use the PublishContainer target.
No Dockerfiles or Docker required.