Using podman compose with ROS2

Prerequisites

sudo pacman -S podman podman-compose

NVIDIA

Install NVIDIA Container Toolkit

sudo pacman -S nvidia-container-toolkit

Configure Container Device Interface (CDI)

# Generate config:
sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml

# (optional) Test config:
nvidia-ctk cdi list

ROS2 Docker images

Compose file library

How to use any of the following compose.yaml files:

  1. Download the desired compose.yaml file.

  2. Make new directory, preferably with descriptive name (e.g. ros2_jazzy_desktop) and move downloaded file to newly created directory.

  3. cd to direcory created in step 2 and run desired command (found under usage).

ROS2

Jazzy

Base

compose.yaml

name: "ros2-base"

services:
  jazzy_base:
    image: "ros:jazzy-ros-base"
    hostname: "ThinkBook-16p"
    privileged: true
    security_opt:
      - "label:disable"
      - "apparmor:unconfined"
    pids_limit: -1
    ipc: "host"
    network_mode: "host"
    pid: "host"
    command: "sleep infinity"

Usage

podman compose run --rm jazzy_base bash

Desktop

compose.yaml

name: "ros2-desktop"

services:
  jazzy_desktop:
    image: "osrf/ros:jazzy-desktop-full"
    hostname: "JazzyDesktop-container"
    privileged: true
    security_opt:
      - label:disable
      - apparmor:unconfined
    pids_limit: -1
    ipc: "host"
    network_mode: "host"
    pid: "host"
    environment:
      DISPLAY: ${DISPLAY}
      XDG_RUNTIME_DIR: ${XDG_RUNTIME_DIR}
      XAUTHORITY: ${XAUTHORITY}
      # WAYLAND_DISPLAY: wayland-0
    volumes:
      - "/run/user/1000:${XDG_RUNTIME_DIR}:rslave"
    command: "sleep infinity"

Usage

podman compose run --rm jazzy_desktop bash