linux - Communication between linked docker containers -


i have 2 docker containers in following setup on host machine:

  • container 1 - udp port 5043 mapped host port 5043 (0.0.0.0:5043:5043)
  • container 2 - needs send data container 1 on port 5043 udp.

scenario 1

  1. i start container 1 , obtain it's ip address.
  2. i use ip address , configure container 2 , start it.
  3. container 2 able send udp data container 1 calling udp://container_1_ip:5043

everything works!!

scenario 2

  1. i start container 1 mapping 5043 udp port host's 5043 port (0.0.0.0:5043:5043)
  2. i link container 2 , container 1 using '--links'.
  3. now, when container 2 invokes url udp://container_1_ip:5043, error thrown "connection refused".
  4. i did verify able ping container 1 inside container 2 using ip.

any scenario 2 working me appreciated!!

as mentioned in docker links:

docker defines set of environment variables each port exposed source container.
each variable has unique prefix in form:

<name>_port_<port>_<protocol> 

the components in prefix are:

  • the alias specified in --link parameter (for example, webdb)
  • the <port> number exposed
  • a <protocol> either tcp or udp

that means need make sure container1 exposes right port right protocol (in case, udp): see "how expose udp port on docker?"


Popular posts from this blog