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

August 4, 2026 3 answers
Asked by VelvetCactus42
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?

Answers

StackedPebble19
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.
Reply to this answer
NorthwindLime8
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.
Reply to this answer
MellowOrbit7
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.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions