UDP port forwarding not working with Docker on Windows 10
Asked Answered
H

0

10

I am running a Docker container for snmptrapd. It runs fine on a Linux host (Ubuntu 18.04), but not on Windows (10 Pro).

Dockerfile:

FROM alpine:3.8

RUN apk --no-cache add net-snmp

COPY mibs/ /usr/share/snmp/mibs
COPY snmptrapd.conf /etc/snmp/snmptrapd.conf
COPY snmp.conf /etc/snmp/snmp.conf

EXPOSE 162/udp

ENTRYPOINT ["snmptrapd","-L","o","-f"]

We also forward UDP port 162 in the Docker run command:

docker run -d --rm -p 162:162/udp snmp_server

A simulated SNMP trap originating from inside the Windows host reaches the container correctly. But any trap originating from outside the Windows host is not reaching the container.

It is not a Windows firewall problem, because I can run Wireshark on the Windows host and see the traps arriving, destination port UDP 162, as expected.

After the container is started, netstat on Windows shows that there is a listener on UDP port 162, bound to all interfaces:

netstat -ano | findstr 162
UDP    0.0.0.0:162            *:*                                    13952
UDP    [::]:162               *:*                                    13952

Inside the container, netstat shows that there is a listener on UDP port 162, bound to all interfaces.

Proto Recv-Q Send-Q Local Address           Foreign Address         State
udp        0      0 0.0.0.0:snmptrap        0.0.0.0:*

Docker version 19.03.1, build 74b1e89

I have tried:

  • --network=host instead of the default bridge mode;
  • --privileged
  • --cap-add NET_BROADCAST

Grasping at straws at this stage!

Habiliment answered 20/9, 2019 at 15:30 Comment(3)
Interesting. You might have better luck on ServerFault tbh.Oleic
Did you find a solution? Seems like there is an ongoing issue with UDP ports and Docker for Windows. I can't get tftp, which uses UDP port 69, to work between a Windows host and Linux container.Bobettebobina
Any update to this pickle?Siouxie

© 2022 - 2024 — McMap. All rights reserved.