Post AvG1QHR5G54tyDHTnc by jorijn@toot.community
(DIR) More posts by jorijn@toot.community
(DIR) Post #AvG16l25Va7fyIHQqe by stux@mstdn.social
2025-06-18T14:20:04Z
0 likes, 0 repeats
Dumb question from a #Docker noob!How does one connect to postgresql on the host machine from a docker container?Since localhost is the container localhost. I tried gateways and even public ip with port but thats baaaad.Also, for #Channel, this URL needs to point to the public or internal(host machine)?https://github.com/patchwork-hub/patchwork_dashboard/blob/daf539aa5c921af4a7435db8acb5fe0d2bf5b249/.env.sample#L17(again localhost = container)
(DIR) Post #AvG1BqDJflGvUKxLaC by jorijn@toot.community
2025-06-18T14:21:07Z
0 likes, 0 repeats
@stux https://docs.docker.com/desktop/features/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host
(DIR) Post #AvG1J9ai1i9Hc4NvRA by stux@mstdn.social
2025-06-18T14:22:29Z
0 likes, 0 repeats
@jorijn hm, this is the compose: https://raw.githubusercontent.com/patchwork-hub/patchwork_dashboard/refs/heads/main/docker-compose.ymlit should be able to reach the internal net right?
(DIR) Post #AvG1NvHSeyd8g5ejWy by phoenixgee@mstdn.social
2025-06-18T14:23:17Z
0 likes, 0 repeats
@stux basically let pg listen on 0.0.0.0 and map its port to the outside
(DIR) Post #AvG1QHR5G54tyDHTnc by jorijn@toot.community
2025-06-18T14:23:45Z
0 likes, 0 repeats
@stux I'm not sure what you are trying to accomplish? Does the dashboard service need to connect to postgres on the host?
(DIR) Post #AvG1QVPpHYOHKMnfma by stux@mstdn.social
2025-06-18T14:23:46Z
0 likes, 0 repeats
@phoenixgee Got that! but for the mapping, is it internal:external in https://raw.githubusercontent.com/patchwork-hub/patchwork_dashboard/refs/heads/main/docker-compose.yml ?
(DIR) Post #AvG1ShSLUDDNFZ1bai by stux@mstdn.social
2025-06-18T14:24:12Z
0 likes, 0 repeats
@jorijn Yes! It runs a container with the dashboard that needs to connect to masto/post on the host itself
(DIR) Post #AvG1UZGetyn8QuRuTo by phoenixgee@mstdn.social
2025-06-18T14:24:35Z
0 likes, 0 repeats
@stux external:internal
(DIR) Post #AvG1VpKwduZAYn3QzQ by jorijn@toot.community
2025-06-18T14:24:40Z
0 likes, 0 repeats
@stux then you should try host.docker.internal:5432
(DIR) Post #AvG1cUnbOrt2tGdeUr by stux@mstdn.social
2025-06-18T14:25:55Z
0 likes, 0 repeats
@jorijn Correct 😉 Post is running on host machine on * basically so it /should/ accept but somehow i could not get the connection to outside the containerthis shouldn't be hard at all 😆
(DIR) Post #AvG1vsnqNWHsq5zoki by jorijn@toot.community
2025-06-18T14:29:29Z
0 likes, 0 repeats
@stux it's basic networking under the hood. Have you tried 172.17.0.1?
(DIR) Post #AvG2byJGIKdo53lFRY by stux@mstdn.social
2025-06-18T14:37:05Z
0 likes, 0 repeats
@jorijn Yup, same result
(DIR) Post #AvG2h2xsPlhbxxB7LM by tknarr@mstdn.social
2025-06-18T14:37:54Z
0 likes, 0 repeats
@stux @jorijn Does Postgres have the TCP port enabled? Common configuration is to use a unix socket only, which works for vanilla localhost but doesn't work when you need a real TCP socket to connect to.
(DIR) Post #AvG7dG6U7e8vKODZ2W by gmarcosanti@mastodon.uno
2025-06-18T15:33:20Z
0 likes, 0 repeats
@stux have you tried turning it off and back on again?
(DIR) Post #AvGFtwWOypYj9So5RI by jasperbuma@mstdn.social
2025-06-18T17:06:00Z
0 likes, 0 repeats
@stux Hey. Also a n00b here. But you can create custom networks. So both containers can see each other. My Joplin server has a network just to connect to the postgresql database and one to connect to my Nginx Proxy Manager.
(DIR) Post #AvGnh8QCp068jgyNhQ by hexaheximal@mstdn.social
2025-06-18T23:24:39Z
0 likes, 0 repeats
@stux I don't know if it will work since there's a decent chance that postgres does some magic with SO_PEERCRED but you may also want to look into forwarding over the unix socket, since in theory that would bypass the TCP/IP stack entirely.