Docker exposed ports are not accessible from all remote networks

Hi @meyay , thanks for the swift response.

First, I use docker compose for all of my containers and here is the compose file for one container which I used for testing:

services:
  bitmagnet:
    image: ghcr.io/bitmagnet-io/bitmagnet:latest
    container_name: bitmagnet
    ports:
      # API and WebUI port:
      - "3333:3333"
      # BitTorrent ports:
      - "3334:3334/tcp"
      - "3334:3334/udp"
    restart: unless-stopped
    environment:
      - POSTGRES_HOST=postgres
      - POSTGRES_PASSWORD=postgres
    #      - TMDB_API_KEY=your_api_key
    volumes:
      - ./config:/root/.config/bitmagnet
    command:
      - worker
      - run
      - --keys=http_server
      - --keys=queue_server
      # disable the next line to run without DHT crawler
      - --keys=dht_crawler
    depends_on:
      postgres:
        condition: service_healthy

  postgres:
    image: postgres:16-alpine
    container_name: bitmagnet-postgres
    volumes:
      - ./data/postgres:/var/lib/postgresql/data
    #    ports:
    #      - "5432:5432" Expose this port if you'd like to dig around in the database
    restart: unless-stopped
    environment:
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=bitmagnet
      - PGUSER=postgres
    shm_size: 1g
    healthcheck:
      test:
        - CMD-SHELL
        - pg_isready
      start_period: 20s
      interval: 10s

I did try it with

networks:
  host:
    external: true

at the end, but this did not have an effect.

The output of the default created network is this:

[
    {
        "Name": "bitmagnet_default",
        "Id": "5b230620e5edecdb4c1603890cb12fdae0488c1ad427365bfc87a0f06a4f4659",
        "Created": "2025-05-02T14:38:50.223475345+02:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv4": true,
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "03af13daec95e914a37cbae0320c46e929bd98d6b78f9dfa8aada035bdb57ca3": {
                "Name": "bitmagnet",
                "EndpointID": "5905bc007d8fe95a2a5a6ffd4f551eaf9fe56ff11faf394a82f24833821231bd",
                "MacAddress": "aa:d5:4d:ab:6b:fc",
                "IPv4Address": "172.19.0.3/16",
                "IPv6Address": ""
            },
            "5e1c1fd459a273edb12858d542088c3f0e692bc5ba93dc8ac1440080cc10ae17": {
                "Name": "bitmagnet-postgres",
                "EndpointID": "d017578a2659867c8515d808346b73a603b275727f831f6b6c481b5ba72ed9c1",
                "MacAddress": "9e:03:62:33:74:82",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.config-hash": "0d2035fd2be972420d0b35a699a00c1e8df43c57b81eb4a0c3828a3b3b24e5af",
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "bitmagnet",
            "com.docker.compose.version": "2.35.1"
        }
    }
]

and here is the output of the info

Client: Docker Engine - Community
 Version:    28.1.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.23.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.35.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 5
  Running: 5
  Paused: 0
  Stopped: 0
 Images: 9
 Server Version: 28.1.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
 runc version: v1.2.5-0-g59923ef
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.1.0-34-amd64
 Operating System: Debian GNU/Linux 12 (bookworm)
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 31.05GiB
 Name: Deb2
 ID: a72346ea-0a39-4590-8061-f108f9c1431c
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Do you think it’s the same issue as this: Exposed ports with net=container: - #5 by sycolth

Sounds like it.