cant connect to MariaDB
Im working on an ASP.NET REST API and I have setup MariaDB on WSL, now im trying to connect to it using ASP.NET from within a docker container but it tells me that its unable to connect. I have already verified that the environment variables are getting set properly
4 Replies
this is my connection string btw
private static string _connectString = $"Server={Utils.DatabaseServer};Port={Utils.DatabasePort};UID={Utils.DatabaseUser};PWD={Utils.DatabasePassword};";
is DatabaseServer by chance
localhost
?
also, don't read env vars like that, use the config system https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/Configuration in ASP.NET Core
Learn how to use the Configuration API to configure AppSettings in an ASP.NET Core app.
@Waffles from Human Resources
if it is "localhost" then it's failing because localhost in the container refers to the container, not your machine
ideally if you're going for a docker setup, then your database would also be in a container
you can stand up and "wire" the containers together with docker compose
I'll check it out tomorrow, and yes the local host refers to my local machine on WSL but it makes sense that it's trying to target the container
Thanks!