Skip to content

hucebot/docker_cams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Docker Compose

This is used to launch through docker compose both realsense camera node and webcam nodes.

1. Docker compose

Assume you want to run both a webcam node and a Realsense node in separate containers (i.e., each coming from a different Docker image/Dockerfile: one containing the webcam code and the other containing the Realsense code).

You can launch them either with two separate docker run commands or with Docker Compose.

However, in both cases, the topics published by each node are automatically visible to the other container only when run from the same laptop. Otherwise, if you want the nodes to communicate, you need additional configuration, such as:

  • Using --network host mode
  • Configuring the same ROS_DOMAIN_ID

This ensures that the ROS2 nodes across containers can see each other and exchange topics. The following is a minimal example:

version: "3.9"

services:
  webcam:
    image: webcam_ros2
    devices:
      - "/dev/video0:/dev/video0"
      - "/dev/video1:/dev/video1"
    command: >
      ros2 launch webcam_pkg my_launch_file.py
      video_device1:=/dev/video0
      video_device2:=/dev/video1

  realsense:
    image: realsense_ros2
    devices:
      - "/dev/video2:/dev/video2"
    command: >
      ros2 launch realsense2_camera rs_launch_file.py

2. Compose usage

  1. Separate repositories/images:

    One repo (or pre-built image) for the webcam node, containing its Dockerfile.

    Another repo (or pre-built image) for the Realsense node, with its Dockerfile.

    The other person either clones the repos and builds the images locally using docker build, or you provide pre-built images on Docker Hub/registry.

  2. docker-compose folder:

    In a separate, empty folder, you put just the docker-compose.yml that references those images.

    The docker-compose.yml defines both services (webcam and Realsense), mounts devices, sets network mode, etc.

  3. Running the setup:

    From that folder, they run:

    docker compose up

    Compose will start two containers (or more if you define more nodes) based on the images.

  4. To stop (and delete) containers activated through compose:

    docker compose down

3. Compose with multiple shells

To launch your nodes and keep them running in the background, you can use compose in detached mode:

docker compose up -d

Then you can open a shell in the running container whenever you want to digit new commands (rostopic list, roslaunch, ...):

docker compose exec webcam bash

4. Additional info

For additional info, make reference to:

https://github.com/hucebot/ros2_ws_webcam

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published