Problem with Docker, VisualStudio and ASP.Net Core
-
Okay, this is a weird one: In order to make things easier once I deploy to production, I wanted to use Docker for one of my ASP.Net Core projects.
Visual Studio spins up the container successfully, the application runs, the browser window then automatically opens and connects to
https://localhost:7282
from where it then successfully load the dev site without any errors or warnings at all.Now, this being a development thing, it's only natural that I'd implement code changes / additions and for that you kind of have to stop the running project and rebuild. Which is where the problem begins: No matter how I stop the project (either by closing the browser window or clicking on "Stop" in VS itself) after a rebuild the browser won't connect to the site anymore. Hell, even if I run the exact same code without any changes the browser doesn't connect. Just sits there and eventually yields a "connection refused" after quite a while.
No errors anywhere. Oh, but connecting cia
https://127.0.0.1:7282/
works but a) it's dog-slow for some reason and b) yields a certificate warning which creates problems at other locations.And the only way to solve this (at least I haven't found another way) is to reboot.
What I've tried:
- deleting the container
- deleting the image
- updating Docker
- restarting Docker
- Docker shutdown then restart
- Docker update
- Disabling of any unneeded Docker features
- restarting VS
This is very weird and I have no clue as to where the problem lies.
-
@Rhywden said in Problem with Docker, VisualStudio and ASP.Net Core:
This is very weird and I have no clue as to where the problem lies.
Welcome to Docker.
-
@Polygeekery said in Problem with Docker, VisualStudio and ASP.Net Core:
@Rhywden said in Problem with Docker, VisualStudio and ASP.Net Core:
This is very weird and I have no clue as to where the problem lies.
Welcome to Docker.
At least I just made sure that it's not something special on my Desktop. My laptop shows the exact same problem.
-
@Rhywden And switching over from WSL2 to HyperV solved the problem. Although they were not lying - it's noticably slower.
Hmmh. Let's see what happens if I switch back again.
-
@Polygeekery said in Problem with Docker, VisualStudio and ASP.Net Core:
@Rhywden said in Problem with Docker, VisualStudio and ASP.Net Core:
This is very weird and I have no clue as to where the problem lies.
Welcome to Docker.
Not a helpful reply.
But completely accurate.
-
@Rhywden said in Problem with Docker, VisualStudio and ASP.Net Core:
the browser doesn't connect. Just sits there and eventually yields a "connection refused" after quite a while.
No errors anywhere. Oh, but connecting cia
https://127.0.0.1:7282/
works but a) it's dog-slow for some reason and b) yields a certificate warning which creates problems at other locations.What kind of certificate error? This smells faintly of IPv6, like your resolver by default only gave you
127.0.0.1
forlocalhost
, but docker somehow enabled IPv6 so it would return::1
which docker didn't actually connect to the container. That would explain why127.0.0.1
works, and probably also the slowness when other stuff tries to connect to localhost and blocks until it gets a timeout and continues with the next DNS result. Usually that doesn't take long, but some packet filters think it was "more secure" to just dropSYN
s to a closed port instead of answering with anRST
, then it can take ages.
Does docker usethehost
network driver?
-
@LaoC Naw, the cert error is expected because the installed developer cert is only valid for
localhost
- that's not related to the problem.Cleaning/purging containers and files seems to have done the trick because WSL2 now works again as well.
-
@Rhywden said in Problem with Docker, VisualStudio and ASP.Net Core:
@LaoC Naw, the cert error is expected because the installed developer cert is only valid for
localhost
- that's not related to the problem.Cleaning/purging containers and files seems to have done the trick because WSL2 now works again as well.
Okay, tried it out. Clean/Purge is not the solution. Instead it's the switch from WSL2 to HyperV (and then back again if so desired).
-
@Rhywden said in Problem with Docker, VisualStudio and ASP.Net Core:
Clean/Purge is not the solution.
It never is but every single Google search about Docker will lead you to believe that it is the ultimate panacea.
Seriously, my best advice is to go right past any result that tells you this and try the next thing. If it seems like I'm advocating for blindly trying random copy/paste shit from web searches, well, as best I can tell that is SOP for Docker. It is a nuclear dumpster fire.
-
@Rhywden said in Problem with Docker, VisualStudio and ASP.Net Core:
@Rhywden And switching over from WSL2 to HyperV solved the problem. Although they were not lying - it's noticably slower.
Hmmh. Let's see what happens if I switch back again.
Oh there's your problem right there, you're on Windows. We had multiple people report huge issues on docker on windows.
-
@Polygeekery I actually quite enjoy docker, its WSL that's a dumpster fire. Get yourself a nice m1 MacBook and your blood pressure will drop without any medication.
-
@dangeRuss did they fix Docker on M1 because I got so frustrated with it that I gave up on local dev containers.
-
@Polygeekery said in Problem with Docker, VisualStudio and ASP.Net Core:
@dangeRuss did they fix Docker on M1 because I got so frustrated with it that I gave up on local dev containers.
What was the problem? It is working for me. Sure, running x64 images on M1/M2, it's quite slow, but that is not actually a docker problem.
Anyway, to the original problem: Always remember that Docker is a Linux thing (well, Windows Docker exists, but so does EBCDIC Unicode; let's forget about them both). If you have "Docker Desktop" on Windows or Mac, it actually runs a complete Linux VM and tries to completely hide this fact. It works quite well... until it doesn't
-
@Polygeekery said in Problem with Docker, VisualStudio and ASP.Net Core:
@dangeRuss did they fix Docker on M1 because I got so frustrated with it that I gave up on local dev containers.
Yeah. Our m1 based devs have massive issues both with speed and stability using docker compared to my Intel Mac.
-
@Polygeekery said in Problem with Docker, VisualStudio and ASP.Net Core:
@dangeRuss did they fix Docker on M1 because I got so frustrated with it that I gave up on local dev containers.
They must've because it works beautifully.
-
@Benjamin-Hall said in Problem with Docker, VisualStudio and ASP.Net Core:
@Polygeekery said in Problem with Docker, VisualStudio and ASP.Net Core:
@dangeRuss did they fix Docker on M1 because I got so frustrated with it that I gave up on local dev containers.
Yeah. Our m1 based devs have massive issues both with speed and stability using docker compared to my Intel Mac.
Thats because they're trying to run x86 based images. Use arm based images and you're the one who will have problems on your puny Intel Mac.
To be fair I don't really use dev containers mostly just build docker lambas with SAM, and random docker images. Seems fairly stable.
-
-
@dangeRuss said in Problem with Docker, VisualStudio and ASP.Net Core:
@Benjamin-Hall said in Problem with Docker, VisualStudio and ASP.Net Core:
@Polygeekery said in Problem with Docker, VisualStudio and ASP.Net Core:
@dangeRuss did they fix Docker on M1 because I got so frustrated with it that I gave up on local dev containers.
Yeah. Our m1 based devs have massive issues both with speed and stability using docker compared to my Intel Mac.
Thats because they're trying to run x86 based images. Use arm based images and you're the one who will have problems on your puny Intel Mac.
To be fair I don't really use dev containers mostly just build docker lambas with SAM, and random docker images. Seems fairly stable.
Doesn't help when our infrastructure, ie the things that will actually run these containers, is Intel.
-
@Benjamin-Hall said in Problem with Docker, VisualStudio and ASP.Net Core:
@dangeRuss said in Problem with Docker, VisualStudio and ASP.Net Core:
@Benjamin-Hall said in Problem with Docker, VisualStudio and ASP.Net Core:
@Polygeekery said in Problem with Docker, VisualStudio and ASP.Net Core:
@dangeRuss did they fix Docker on M1 because I got so frustrated with it that I gave up on local dev containers.
Yeah. Our m1 based devs have massive issues both with speed and stability using docker compared to my Intel Mac.
Thats because they're trying to run x86 based images. Use arm based images and you're the one who will have problems on your puny Intel Mac.
To be fair I don't really use dev containers mostly just build docker lambas with SAM, and random docker images. Seems fairly stable.
Doesn't help when our infrastructure, ie the things that will actually run these containers, is Intel.
And rebuilding the image with the same Dockerfile save for a different base image doesn't work? :dockering_it_wrong:
-
@Benjamin-Hall said in Problem with Docker, VisualStudio and ASP.Net Core:
@dangeRuss said in Problem with Docker, VisualStudio and ASP.Net Core:
@Benjamin-Hall said in Problem with Docker, VisualStudio and ASP.Net Core:
@Polygeekery said in Problem with Docker, VisualStudio and ASP.Net Core:
@dangeRuss did they fix Docker on M1 because I got so frustrated with it that I gave up on local dev containers.
Yeah. Our m1 based devs have massive issues both with speed and stability using docker compared to my Intel Mac.
Thats because they're trying to run x86 based images. Use arm based images and you're the one who will have problems on your puny Intel Mac.
To be fair I don't really use dev containers mostly just build docker lambas with SAM, and random docker images. Seems fairly stable.
Doesn't help when our infrastructure, ie the things that will actually run these containers, is Intel.
You're not on the cloud?