title: docker: how to do/setup networking container-to-host for udp / snmp
body: <p>I'm using docker for mac, and I'm running an snmp server inside a container, to which I usually send GET requests. For send/receive, docker networking works, as it'll forward/inbound to localhost port to the container. </p>
  
  <p>Where this doesn't work is for outbound, i.e. when the container software needs to send to another machine, or in this case, the host (use case: test snmp traps). It's not very clear how can I access the host back, and how/where can the host listen.</p>
  
  <p>Typically I'd like the container server to send the packet to its localhost:162, but for this to be forwarded to an exposed port to the host machine:</p>
  
  <pre><code>(container)localhost:162 -&gt; (host)localhost:32778 (p.ex)
  </code></pre>
  
  <p>So that I could <code>nc -ul 32778</code> and see the packets arrive.</p>
  
  <p>I'd prefer to set this up with pure docker, docker-compose and the like aren't an option. </p>
  
  <p>Does anyone have experience with this?</p>