Run 2 nodes in two separate docker containers

thinwybk edited this page Feb 6, 2018 · 2 revisions

Open a terminal. Run the image in a container in interactive mode and launch a topic publisher (executable talker from the package demo_nodes_cpp) with ros2 run.

$ docker run -it --rm osrf/ros2:ardent-basic ros2 run demo_nodes_cpp talker

Open a second terminal. Run the image in a container in interactive mode and launch a topic subscriber (executable listener from the package demo_nodes_cpp) with ros2 run.

$ docker run -it --rm osrf/ros2:ardent-basic ros2 run demo_nodes_cpp listener

As alternative to the command line invocation you can create a docker-compose.yml file (here version 2) with the following (minimal) content.

version: '2'

services:
  talker:
    image: osrf/ros2:ardent-basic
    command: ros2 run demo_nodes_cpp talker
  listener:
    image: osrf/ros2:ardent-basic
    command: ros2 run demo_nodes_cpp listener
    depends_on:
      - talker

To run the containers call docker-compose up in the same directory. You can close the containers with Ctrl+c.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.