this post was submitted on 19 Nov 2024
16 points (94.4% liked)

Selfhosted

40296 readers
344 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

Hello everybody! I have the following issue: I have two countainers, let's call them C1 and C2, and they both expose the same port, let's say 1234. I want to route both of them through a gluetun container. to do this, I added

network_mode: container:gluetun

at each container. But they both expose the same port, so there's a conflict. Without routing them though gluetun I can just

ports:
  - 1235:1234

but using network_mode this cannot be done. What can I do? The only thing that comes to my mind is to use two gluetun containers, but I'd rather use a single one

thanks in advance!

you are viewing a single comment's thread
view the rest of the comments
[–] emax_gomax@lemmy.world 4 points 1 day ago (1 children)

I funnily had the same use case. Two different jellyfin servers for complete separation. Both routing through gluetun. The reason this doesn't work is because the network mode setting you have basically makes all three containers operate in the same network. Meaning if one binds a port the others can no longer bind the same port. Their different hosts but all sharing one network and port range. To expose the ports you can move that ports setting from C1/C2 to the gluetun service definition. This'll still work because when C1 binds to 1234 it'll be reachable through the gluetun service.

Note: as mentioned if C1 and C2 cannot use the same port if you also want to have service gluetun set. More likely than not you start C1, it binds to the port, start C2, it tries and fails to bind to the port and crashes. I fixed this by making one of my jellyfin containers use a separate port. If you can't configure the ports of your services then there's no real recourse FWIU.

[–] tubbadu@lemmy.kde.social 1 points 18 hours ago

If you can’t configure the ports of your services then there’s no real recourse FWIU

Sadly this is my case... I guess I'll have to give up then thank you very much!