I have a docker container that needs to expose 10,000 ports

I have a solution for this.

  1. run with userland-proxy=false
    In /etc/docker/daemon.json {“userland-proxy”: false}
    Don’t use -P or -p on the docker create/run command line.
    Manually put in iptables rules:
    CIP=$(docker inspect --format=’{{.NetworkSettings.IPAddress}}’ container)
    iptables -A DOCKER -t nat -p udp -m udp ! -i docker0 --dport 10000:20000 -j DNA
    T --to-destination $CIP:10000-20000
    iptables -A DOCKER -p udp -m udp -d $CIP/32 ! -i docker0 -o docker0 --dport 100
    00:20000 -j ACCEPT
    iptables -A POSTROUTING -t nat -p udp -m udp -s $CIP/32 -d $CIP/32 --dport 1000
    0:20000 -j MASQUERADE

https://hub.docker.com/r/bettervoice/freeswitch-container/

1 Like