When enabling port listening on Docker, it is set to listen on all interfaces by default, including your local network and any public interfaces.
To verify this, you can use Telnet with the public IP:
If you want to limit the listening to the local network or localhost only, you cannot do this:
This will result in an error:
Instead, use a direct IP address:
To verify, test it with Telnet again. You should see something like this when accessing it via the public IP.
Or using netstat
:
If your container is already running using Docker Compose, you can’t just restart it; you need to take it down and bring it back up again.
In my case, I am now able to proxy my Docker container using Nginx proxy pass and set the upstream to localhost:3100.