dokku / dokku-graphite

a graphite, grafana, statsd, carbon plugin for dokku
MIT License
56 stars 13 forks source link

Docker expose uses TCP for all ports, but 8125 needs UDP #12

Open lsalvadorini-c4w opened 7 years ago

lsalvadorini-c4w commented 7 years ago

I've installed the plugin and tryed to expose the port of StatsD to use it from a non containerized app on another host.

The ambassador container starts correctly but expose the 8125 port using TCP and not UDP, is it possibile to have StatsD port exposed as UDP?

matteing commented 4 years ago

Bump - also facing this issue. Can't access StatsD externally due to this, resorted to a bit of a hack messing with docker.

EDIT: The fix would probably be by modifying this line to do this.

I'd do a push request but my bash skills are practically nonexistent. :P

matteing commented 4 years ago

UPDATE: I found a temporary workaround to the problem, although it's quite involved.

  1. Unexpose the Graphite ports.
  2. Expose them, but set the StatsD port to a different port than usual. In my case, I set it to 8120.
  3. Get the Docker internal IP for the non-ambassador Graphite docker instance.
  4. Set up a socat pipe to redirect the UDP traffic to the Docker Graphite instance.
# Get the IP for the non-ambassador Docker container
sudo docker container ls --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}" -a
# Inspect that container, find its IP 
sudo docker inspect c28099211a37 | grep IPAddress
# Setup a socat proxy to redirect UDP traffic from 8125 on the host to 8125 on non-ambassador Graphite
sudo docker run -d --rm -p 8125:1234/udp verb/socat:alpine -d -d UDP4-LISTEN:1234,reuseaddr,fork UDP4:172.17.0.6:8125