TheOneCurly@kbin.socialtoSelfhosted@lemmy.world•NPM + Docker Containers = 502 Bad Gateway
1·
1 year agoRepost from kbin directly since federation is being weird.
I use a similar setup with dockerized NPM. I see 2 things in this example that I do differently.
- Make sure to explicitly call out
external: true
in the network definition. I’m not sure what compose will do if you don’t. But I wouldn’t want it making any new proxy networks accidentally. - proxy should be in the
networks
list for each container you want accessible from NPM. I don’t believe just defining it in the compose adds all containers to that automatically.
Ah ok I think I see some of the confusion. Docker networking is a little weird and imo compose abstracts a little too much away.
If 2 containers are on the same docker network they are exposing all their internal ports to each other with individual virtual network adapters. This is really nice because there’s no issues with port overlap, each container has its own hostname and virtual adapter with all ports available.
The port mapping actually binds the internal port of the container to the port on your host. This is useful for applications outside of docker to connect directly, but not necessary for anything you want behind the reverse proxy anyway.