Listening to ROS messages in Docker containers
I have been working with Docker as a host for my ROS nodes. It's a great way to do it, but I have hit a problem.
I can use docker-compose to spin up containers, and they all merrily talk to one another. But during the development phase I want to be able to listen in too, use something like RViz, etc. The nodes are on a headless machine. Developers can't really just spin up the containers on their own computers as the headless machine has the hardware like cameras attached to it.
So is there a cunning way to do this? I have got overlay networking going, but I can't see a good solution using that either. The only thing I could see to do with that is to join the overlay network, spin up a container and run RViz inside it and forward the X session out. However, joining the overlay network also doesn't work if you are ssh'ing into the main machine from behind a firewall/NAT.
Do you have a single master? Is that running in a separate container, or as part of one of the node-containers? Also: can all containers communicate with all other containers, or are there partitions?
Single master. Every node (including master) is running in a separate container. Every container can communicate with every other one.
I have not used overlay networks, but apart from NAT, do you see any issues with 'just' setting
ROS_MASTER_URI
on your host to the IP of yourroscore
container and starting RViz (or whatever tools you need)?I need a way to have my machine resolve the names of the other containers. I have done as you suggested on the host computer and it works if I spin up a
resolver
container. But it won't work from anywhere else - another PC on the LAN cannot resolve and talk to the IP addresses of the containersWell, a non-Docker-onic solution / work-around could be to run a VPN server in one of the containers in your ROS network and connect to that from your remote host. That would make the remote host 'local' in a sense. Other work-around: IP routing the remote host into the containers' network.
Another work-around: set
ROS_IP
on all involved containers to their IP, and setROS_MASTER_URI
to the IP of theroscore
container. That would avoid the DNS problem. Be sure to setROS_IP
on your remote host as well.And as far as I understand overlay networks: would it work if your remote host is part of the same overlay network as all your ROS containers?