How can I avoid container IP changes breaking Pangolin after a VPS restart?

0
0
Asked By VelvetCactus42 On

I'm running Pangolin on a VPS with several Docker containers, and they're currently configured with network_mode: pangolin. After the VPS restarts, Docker assigns different IP addresses to the containers, so Pangolin keeps trying to use the old addresses and returns bad gateway errors. Is there a way to assign stable IP addresses in Docker Compose without creating a separate network for every container, or is there a better way to configure the services?

3 Answers

Answered By MellowOrbit7 On

You generally shouldn’t configure Pangolin to connect to containers by their changing IP addresses. Use the container or service name instead—Docker’s internal DNS will resolve that name to the current container IP after a restart. That way, Pangolin continues reaching the right service even when Docker assigns a new address.

VelvetCactus42 -

That fixed it. I didn’t realize Pangolin could use the container name as the address, but it works after restarting the VPS now.

Answered By NorthwindLime8 On

A macvlan network would give containers addresses on the physical network, but it doesn’t really solve this problem and is often awkward on a VPS. Container IPs are expected to change; applications should normally connect through Docker DNS and service names instead. Static IPs are mainly useful when something outside Docker cannot use DNS or service discovery.

Answered By StackedPebble19 On

Using network_mode for every container is probably the wrong setup. Only the relevant Pangolin proxy service should share the special network namespace, such as network_mode: service:gerbil if that is what the stack requires. The other containers should share a normal user-defined Docker network with the appropriate Pangolin or Newt service. Docker’s built-in DNS can then resolve them by service name. Sharing one network namespace across everything can also cause port conflicts.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.