Exposed docker ports not accessible on public IP

Hi,

I have installed Docker on a VPS running Debian and I’m trying to expose one of the ports from the container to the host.

While it is accessible on 127.0.0.1, when I try to connect to it using the public IP of the VPS, it is not accessible.

This is a fresh install of Debian, so no firewall is active or anything like that.

Does anybody know why this is the case?

Many thanks.

Can you show how you do it? If you mean you use the “expose” parameter or Dockerfile instruction, that is not enough. You need to forward ports.

So if you can run for example curl http://127.0.0.1:PORTNUMBER to access the service, it means that you either forwarded the port from your localhost only, or you do have some firewall even if you did not install any.

Hi,

So this is my docker composer file:

version: "3.3"
services:
  qbittorrent-vpn-service:
    volumes:
      - "./data:/data"
      - "./config:/config"
    environment:
      - VPN_ENABLED=yes
      - VPN_CLIENT=openvpn
      - VPN_PROV=custom
      - LAN_NETWORK=192.168.1.0/24
      - DEBUG=true
    ports:
      - "7000:8080"
      - "7001:8118"
    cap_add:
      - NET_ADMIN
    image: binhex/arch-qbittorrentvpn

And the ports are binding to 0.0.0.0. So, it should work right? Not sure why it is not. What would I have to do to forward the ports to the public IP?

You don’t forward port TO the public IP but FROM the public IP TO the container. Since your container has NET_ADMIN capability and you also use VPN, try an other container without VPN just to make sure that the port forward works with a simple container like nginx so you can open the main page from the browser using the public IP.