Meteor DDP call between containers on same host

This Meteor App server code tries to use the method of another Meteor worker. both the app and the worker are in a separate docker containers on the same server EC2. The worker is running on port 9000.
When the App fires a method appCallingWorker, I expected to see the worker container logs out the string ‘worker called from App’ but all docker logs containerID gives is many lines looking like this:
stream error Network error: ws://localhost:9000/websocket: connect ECONNREFUSED 127.0.0.1:9000

How can I use the methods of the worker from the App? thx

  • Emails not working in Linux Containers
  • Cannot login to docker container registry which is inside docker container
  • Upgrade from Docker 1.08 to 1.10
  • Docker for windows issue while installing and running
  • Docker Rails App and postgres
  • running docker remotely on openvz
  • //App/server/main.js
    let workerConn = DDP.connect('http://localhost:9000');
    Meteor.methods({
     'appCallingWorker': () => {
       workerConn.call('workerMethod');
      }
    });
    
    //Worker/server/main.js
    Meteor.methods({
      'workerMethod': function () {
        console.log('worker called from App');
      }
    })
    

    edit
    The EC2 is a Container Instance in AWS ECS. and the containerDefinitions.portMapings.containerPort and hostPort are both set to 9000.
    edit 2
    iptables -L -n on the docker host shows the ip of the container listening on 9000, I replaced localhost in the code with said ip and now it works. But Said ip can change if host reboot or container restarts… another problem to find a solution for.

  • How to setup HTTP Routing Mesh (HRM) in docker datacenter community edition?
  • DOCKER_OPTS are reset after system reboot
  • Mounting nginx conf as a docker volume causes system error boot2docker
  • Unable to run docker or service docker
  • How do I put a docker container in an error state?
  • Docker - how to set iface name when creating a new network
  • One Solution collect form web for “Meteor DDP call between containers on same host”

    i had this same problem trying to communicate between docker containers. you’re going to have to use the external ip:port address of the server your containers are on.

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