lancachenet / monolithic

A monolithic lancache service capable of caching all CDNs in a single instance
https://hub.docker.com/r/lancachenet/monolithic
Other
746 stars 75 forks source link

Port binding does not appear to work with host with multiple IP's #121

Closed deranjer closed 3 years ago

deranjer commented 3 years ago

Describe the issue you are having

I have to manually modify the nginx config to force port binding to a specific interface (I have 4 physical NIC's on my server). In docker-compose I am force binding it to interface "192.168.1.33:80:80" and "192.168.1.33:443:443". I have to force bind it to an IP, since I have traefik running on "192.168.1.30:80:80" and 443. However, when attempting to start the container it can't bind to 80 or 443 since those ports are "already in use". So I copied the nginx folder out of the docker and then bound them, modified the nginx conf files to force bind to that IP, and now it starts up just fine and my access logs start showing hits.

Am I doing something wrong here? This may be more of a docker issue if I am configuring the docker-compose incorrectly.

How are you running the container(s)

  lancache:
    image: lancachenet/monolithic:latest
    container_name: lancache
    restart: always
    network_mode: "host"
    ports:
      - 192.168.1.33:80:80
      - 192.168.1.33:443:443
    volumes:
      - /mnt/RemoteStorage/caches/data:/data/cache
      - /mnt/data/lancache/logs:/data/logs
      - /mnt/data/lancache/nginx:/etc/nginx
      - /mnt/data/lancache/logs/nginx:/var/log/nginx

DNS Configuration

I just have my pihole dnsmasq configured to point the specified hostnames to lancache

deranjer commented 3 years ago

Apparently I needed to setup docker networks differently before this would work:

  lancache:
    internal: false
    driver_opts:
      com.docker.network.bridge.host_binding_ipv4: "192.168.1.32"

Then attach lancache to that network and it worked fine.

GotenXiao commented 3 years ago

For future reference of anyone finding this issue, this is documented behaviour for Docker when using host networking.