By default, can a docker container call host's localhost UDP?

I have a docker container, and also installed on the VM a daemon listening for UDP on port 8125. The container sends data with UDP protocol on this 8125 port.

I was trying to open the port by starting the container with the -p 8125:8125/udp, but I’m getting the following error:

  • How do I define the name of image built with docker-compose
  • Run a Docker image as a command line utility in Windows?
  • Docker DNS Server not contactable outsid container
  • Unable to run build for gitlab-ci
  • java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing
  • nginx 405 - uploading img from ember to rails
  • Error starting userland proxy: listen udp bind: address already in use

    Which makes sense because the daemon is already listening on this port.

    So how can I configure Docker so that the container can send UDP payloads to the external daemon ?

  • kube-addons.service failed on CoreOS-libvirt installation
  • javax.naming.NameNotFoundException: Name [jdbc/projectCon] is not bound in this Context. Unable to find [jdbc]
  • How to push/build a docker image in release process via sbt-release
  • Do you have any resource explaining how to use Firebase Test lab with GitLab pipeline?
  • How to set Docker-compose arguments in console?
  • My travis-ci yml for docker seems a little verbose - am I using docker run incorrectly?
  • One Solution collect form web for “By default, can a docker container call host's localhost UDP?”

    Opening ports is only needed when you want to Listen for the requests not sending. By default Docker provides the necessary network namespace for your container to communicate to the host or outside world.

    So, you could it in two ways:

    1. use --net host in your docker run and send requests to localhost:8125 in this case you containerized app is effectively sharing the host’s network stack. So localhost points to the daemon that’s already running in your host.

    2. talk to the container network gateway (which is usually or your host’s hostname from your container. Then your are able to send packets to your daemon in your host.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.