0
$\begingroup$

Rosanswers logo

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?


Originally posted by Niesky on ROS Answers with karma: 11 on 2016-09-27

Post score: 1


Original comments

Comment by gvdhoorn on 2016-09-27:
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).

Comment by gvdhoorn on 2016-09-27:
Maybe related: Listening to ROS messages in Docker containers.

Comment by Niesky on 2016-10-03:
@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.

Comment by Niesky on 2016-10-03:
@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.

Comment by ruffsl on 2016-10-15:
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

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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


Originally posted by ruffsl with karma: 1094 on 2016-10-17

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$
0
$\begingroup$

Rosanswers logo

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

Originally posted by waspinator with karma: 122 on 2017-02-03

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.