It is possible to docker-compose to forward a port to the container from localhost
only, by writing the desired ports
configure in docker-compose.yml
, e.g. 127.0.0.1:8080:80
.
In docker swarm this does not work and the published port is visible from the internet.
How then can I access the container port only from localhost without opening the port to the internet?
I tried configuring iptables to deny connection to port iptables -A INPUT -p tcp --dport 5432 -j DROP
, but because of the settings from docker for iptables, that didn't work.
-I
instead of-A