Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Wack61915yI mean, it's not best practice, but have you considered running the DB as another docker container? :P
And otherwise either use the host ip stuff provided by docker or pass the socket to the container.
What might be an issue, when using the ip based method, is that a lot of DBs Block access by default, if it's not comming from localhost, so make sure, that's not the case. -
epse36585yAs said above, double check that traffic from your containers ip is allowed (it doesn't come from local host!) and that the container knows the ip to connect to
-
Wack61915yOooof mongo. Good luck :P
Are you able to successfully connect to mongo from your host?
Edit: if you're using ip based: make sure to try to connect to 127.0.0.1 on your host, as it might fall back on socket if no ip/localhost is given.
If host to mongo works, open the port to the web and try from another computer. If that works, try again from the container. If it works, close the port again and try it again from the container -
@Wack Yup that works just fine! But I'm really wondering why I can't even see the port as open while it's listening on that goddamn ip..
-
Doesn't mongo have a Unix socket? That would be an easy bind on your run command, unless your client doesn't support it.
-
Lythenas2425yIf you access something not by ip but by dns name from inside a docker container it doesn't always work because docker has its own dns server that does not respect all local dns resolver settings.
But can't remember how I fixed that... -
Been there. Docker has some predefined hostname to access host system. Not sure what it’s called though.
-
Your container website cannot connect to db on your host machine? well by default, containers go on a different network 172.xx.xx.xx
Either move database to a container and make sure you map data folder to docker volume or every restart of that docker will reset the state of your database.
And also make sure your website container resolve DB container by name rather than by IP -
LMagnus20575yYou can use host.docker.internal as the host if the db is on the local machine running the container.
-
@LMagnus Tried that, its unreachable/doesn't exist according to the container 😅
-
Wack61915yCan you ping other domains? Like can you ping duckduckgo or something Like that from inside the container? I kind of get the feeling, the containers networking is fucked...
"Let's quickly make sure that the docker container can access a host database"
I guess I can put that quickly up my ass.
How motherfucking difficult can this be?!
rant