![](https://media.kbin.social/18/70/1870c144bf44523e33f51af29fce85186f1bca7ecdd5f9eb35b74c7a5d48c000.jpg)
![](https://slrpnk.net/api/v3/image_proxy?url=https%3A%2F%2Flemmy.world%2Fpictrs%2Fimage%2F8286e071-7449-4413-a084-1eb5242e2cf4.png)
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.