Remove unneeded ports from docker-compose.yml and
docker-compose.override.yml
Don't expose any ports except port 3000 to outside the Docker environment, and only expose port 3000 to the Docker host's loopback interface (127.0.0.1 and [::1]).
Merge request reports
Activity
requested review from @anusha
added Waiting to be tested label
I think there's a misunderstanding on how
docker-compose.yml
files work.Quote from Docker's documentation on compose files:
By default Compose sets up a single network for your app. Each container for a service joins the default network and is both reachable by other containers on that network, and discoverable by them at a hostname identical to the container name.
Networks
In our case, there actually is a custom
network
with the name ofinternal
defined, and all containers are connected to that samenetwork
.
Side note: The nameinternal
is probably not the best name choice here, because anetwork
can also have a property calledinternal
, which configures whether outbound connections (from containers in thatnetwork
to the internet) should be forbidden (the default value for thatinternal
flag isfalse
, so by default, outbound internet connections are allowed). This would then look like this (the firstinternal
is thenetwork
, the second one is the configuration flag):networks: internal: internal: true
Ports
The
ports:
setting is completely orthogonal to this, and configures wheter a port of a container should be exposed to the Docker host or via the Docker host's own network interface (opening a pass-through listener on the Docker host on either127.0.0.1:$portnumber
or0.0.0.0:$portnumber
).The
ports:
directive does not configure/define connections between containers (unless you expose container A's port on all of the host's network interfaces and then have container B connect to that exposed port on the host - but that would clearly not be the intended usage of these features).tl;dr
- All containers that are connected to the same Docker
network
can connect to each other on all ports. - In RDMS, currently all containers are connected to the same network, so they can all connect to each other on all ports.
- At least in our setup, the
ports:
directive is only needed to expose the web container's web server port (TCP port 3000 in our case) to the host, such that our nginx reverse proxy can connect to theweb
container's port 3000 when adding TLS and reverse-proxying that port to port 443 on the public network interface.
Edited by Pascal Ernster- All containers that are connected to the same Docker