Day 3 (of real work)

·

2 min read

Reached a small, but mighty milestone today. For the last 2 days, I spent having an existential crisis on if my project structure is going to work. Basically, it started off with me trying to connect to my postgres database withing my .NET application which is containerized. Like I said in my last post, using localhost wont work since localhost to a docker container is itself. Because of that small hiccup, I went on a research frenzy about how docker works, whether I should delete the database I created and dockerize that. Basically everything you could think of.

This stemmed from a few things, one is I created my docker container using visual studio. AKA I didn't write it myself. Because of this, whenever I tried to run the container from PowerShell, the container would spin up, but the actual .NET code would not run. I couldn't find anything online about this either so I figured while my application is small, why don't I just restart with a docker container I write instead. Surprise surprise, I did that and I had issues with that also. Ultimately, I took a step back and realized that I was spending so much time over something fairly small, when I could just move forward with the generated docker file and write the actual code for the application. All I needed to do to access my database was replace 'localhost' with 'host.docker.internal' and poof, it connected.

I still never found out what command visual studio uses to run the container but for now I'll just forget it and worry about it when it comes time to deploy my application.

TLDR, spent 3 days learning and ended up doing the simple solution I found on the first day.

Did you find this article valuable?

Support Cocode Dev Blog by becoming a sponsor. Any amount is appreciated!