ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to connect nodes in docker to remote master?

asked 2016-09-27 04:07:56 -0500

Niesky gravatar image

I have two machines A and B in the same network. A is running roscore on address http://192.168.1.101:11311 , and running a node, say rospy_tutorials listener.py B is running docker container for some other nodes, say ros_tutorials talker.py.

I have tried to use --env ROS_MASTER_URI=http://192.168.1.101:11311 on machine B, but the roscore on A can not detect the correct address for the node inside docker on B. I suppose the docker is blocking all ports by default.

How should I set up the docker parameter so that everything works?

edit retag flag offensive close merge delete

Comments

Using multiple containers is no different from using multiple machines: you need to make sure to either not use hostnames anywhere (set ROS_IP), or make sure all containers can resolve hostnames successfully. Also: make sure you have your containers share a network (docker0 or something else).

gvdhoorn gravatar image gvdhoorn  ( 2016-09-27 04:30:40 -0500 )edit
gvdhoorn gravatar image gvdhoorn  ( 2016-09-27 04:31:17 -0500 )edit

@gvdhoom I tried to set ROS_IP for every node, still not working. If every nodes are launched by docker, then thing works. But note that some nodes are running on remote machines (inside same LAN) other than docker host, the problem occurs.

Niesky gravatar image Niesky  ( 2016-10-03 21:21:49 -0500 )edit

@gvhoom My guess is that ROS requires bi-directional connection on all ports for all nodes. But docker shield the nodes inside containers from receiving/sending messages on arbitrary port.

Niesky gravatar image Niesky  ( 2016-10-03 21:23:10 -0500 )edit

This may be related: Exposing ROS Containers to Host Machine
Not sure of a way to do that; web apps normally just expose single ports to host. you'd almost need the container's IP to resolve from that 192... domain

ruffsl gravatar image ruffsl  ( 2016-10-15 00:53:44 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-10-17 17:46:41 -0500

ruffsl gravatar image

It looks like this is now be possible by using support for the new Macvlan and IPvlan network drivers. The Docker documentation for both network drivers can be found here.

I just found this out by from stackoverflow:
Docker 1.10 container's IP in LAN

edit flag offensive delete link more
1

answered 2017-02-03 18:23:19 -0500

waspinator gravatar image

updated 2017-02-03 18:24:33 -0500

Try setting static IPs for the nodes.

version: '2'
services:
  master:
    build: .
    container_name: master
    command:
      - roscore
    environment:
      - "ROS_IP=172.19.0.100"
    networks:
      ros_net:
        ipv4_address: 172.19.0.100
    ports:
      - "11311:11311"
      - "33690:33690"

  talker:
    build: .
    container_name: talker
    environment:
      - "ROS_IP=172.19.0.101"
      - "ROS_MASTER_URI=http://172.19.0.100:11311"
    command: rosrun roscpp_tutorials talker
    networks:
      ros_net:
        ipv4_address: 172.19.0.101

  listener:
    build: .
    container_name: listener
    environment:
      - "ROS_IP=172.19.0.102"
      - "ROS_MASTER_URI=http://172.19.0.100:11311"
    command: rosrun roscpp_tutorials listener
    networks:
      ros_net:
        ipv4_address: 172.19.0.102

networks:
  ros_net:
    driver: bridge
    ipam:
      driver: default
      config:
      - subnet: 172.19.0.0/24
        gateway: 172.19.0.1
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2016-09-27 04:07:56 -0500

Seen: 5,126 times

Last updated: Feb 03 '17