I have my main compose file which has a bunch of services in and while it makes it easier to manage, it’s also limiting when I wanna use postgres:// to access a database rather than exposing a port. I’m wondering if I can remedy this by moving it to a new network and(?) stack?

If so, is it just as simple as adding

networks
  - new network name
stacks
  - new stacks name

I’m still curious as to the answer, but it’s not something I need.

  • sabreW4K3OP
    link
    fedilink
    arrow-up
    1
    ·
    7 months ago

    First off, apologies for the delay. But my brain just didn’t wanna think about compose yesterday.

    Okay, so the reason I’ve ended up with postgres://username:password@ipaddress:port was because I’m running a bunch of different postgres databases within the compose file and once I removed the port, compose kept trying to look at the wrong database. What I was essentially trying to do was get it to look for the right database by creating its own stack and network and then not having to open the port to the outside.

    Does that make sense? I could totally be overthinking things.

    • lemmyvore@feddit.nl
      link
      fedilink
      English
      arrow-up
      2
      ·
      7 months ago

      Try using the postgres hostname instead of “ipaddress”, it should work. Postgres doesn’t have to be exposed on host for this to work, and all compose files will automatically create a bridge network for all services defined in it so you don’t technically need to make an explicit network (unless you really need to define IPs or MACs or some other parameters).