How to bind docker-compose to ip+ port + protocol?

94 views Asked by At

I'm trying to make a pi-hole container listen only on one of my server's IPs (I have multiple netowrk cards), the other one is forwarded through the firewall, but I need to listen to port 53 (UDP & TCP), so I'm basically facing this problem:

pihole:
    ...
    ports:
        - "10.1.0.5:53:53/udp" # this will not work
        - "10.1.0.5:53:53/tcp"
    ...

I've checked Docker's published ports documentation, and it appears that ports can only specify either an IP to bind to, OR a protocol, not both, for some reason. Is there another way to do this? Am I missing something? Did I miss-read the docs?

1

There are 1 answers

0
Coding Neko On BEST ANSWER

Nevermind, apparently it was something else that was failing, I am not sure what exactly, but the code in my question is correct. I'll leave this up in case anybody else is wondering how to do this, this is my docker-compose's ports section:

ports:
  - "10.1.0.5:53:53/udp"
  - "10.1.0.5:53:53/tcp"
  - "10.1.0.5:8084:80"