Hot-plug devices into a Docker container as they are plugged.

Overview

container-hotplug

Hot-plug (and unplug) devices into a Docker container as they are (un)plugged.

Description

Docker provides the --device flag to give a container access to a device. However the devices specified this way must be present when the container is created.

For dynamically created devices Docker provides the --device-cgroup-rule. However this requires knowing the device's major and minor numbers, which are dynamically allocated by the kernel. The rule accepts a glob * to mean "any minor" or "any major". However this would still give the container access to all the devices handled by a particular driver.

This program tries to solve that problem by listening to udev events to detect when a device is (un)plugged. It then interfaces directly with the container's cgroup to grant it access to that specific device.

To limit the devices the container can access, a root device is specified. The container will receive access to any device descending from the root device. This is particularly useful if the root device is set to a USB hub. However, since hubs are rarely interesting, it can be specified as "the parent of device X", e.g., we can giving a container access to all devices connected to the same hub as an Arduino board.

Another concern is providing a container with well known paths for the devices. On bare-metal systems this would usually be achieved with a SYMLINK directive in a udev rule. This program tries to provide a similar functionality for containers, allowing you to specify symlinks for certain devices.

Limitations

container-hotplug needs to be run as root and relies on cgroup v1. It does not support cgroup v2. On distributions with cgroup v2, you can switch back to cgroup v1 by setting the kernel parameter systemd.unified_cgroup_hierarchy=0.

Example

Give a container access to all devices connected to the same hub as a CW310 board.

  1. Find the USB VID and PID of the device using lsusb, for a CW310 that is 2b3e:c310
  2. Run (as root) the container using container-hotplug:
container-hotplug run \
    -d parent-of:usb:2b3e:c310 \
    -- -it ubuntu:22.04 bash

If you want symlinks to the tty devices created by interfaces 1 and 3 of the CW310, run:

container-hotplug run \
    -d parent-of:usb:2b3e:c310 \
    -l usb:2b3e:c310:1=/dev/ttyACM_CW310_0 \
    -l usb:2b3e:c310:3=/dev/ttyACM_CW310_1 \
    -- -it ubuntu:22.04 bash
You might also like...
Docker images for compiling static Rust binaries using musl-cross

rust-musl-cross Docker images for compiling static Rust binaries using musl-cross-make, inspired by rust-musl-builder Prebuilt images Currently we hav

Valheim Docker powered by Odin. The Valheim dedicated gameserver manager which is designed with resiliency in mind by providing automatic updates, world backup support, and a user friendly cli interface.
Valheim Docker powered by Odin. The Valheim dedicated gameserver manager which is designed with resiliency in mind by providing automatic updates, world backup support, and a user friendly cli interface.

Valheim Docker If you are looking for a guide on how to get started click here Mod Support! It is supported to launch the server with BepInEx but!!!!!

Rocker is a minimal docker implementation for educational purposes.
Rocker is a minimal docker implementation for educational purposes.

Rocker is a minimal docker implementation for educational purposes inspired by gocker. Rocker uses linux kernel features (namespace, cgroup, chroot etc.) to isolate container processes and limit available resourses.

Tool to monitor the statistics and the energy consumption of docker containers
Tool to monitor the statistics and the energy consumption of docker containers

Docker Activity Docker activity is a tool to monitor the statistics of your containers and output their energy consumption. Warning It's still in earl

🐳 📦 Bringing docker containers to your AUR helper since 2022

zeus Releases | CI | Issues | Installing | Building Zeus. A simple AUR helper which utilizes docker containers allowing developers and users alike to

Loads environment variables into your structs in one shot.
Loads environment variables into your structs in one shot.

econf Loads environment variables into your structs in one shot. econf allows to override struct fields with environment variables easily. This is use

Isolates Jibri pods from their Deployment when they start recording or livestreaming, and cleans them up when they finish.

jibri-pod-controller: A tool for managing the scaling of large Jibri deployments in Kubernetes. When managing a large Jibri deployment, you usually wa

Shallow Container is a light-weight container tool written in Rust.
Shallow Container is a light-weight container tool written in Rust.

Shallow Container is a light-weight container tool written in Rust. It is totally for proof-of-concept and may not suit for production environment.

A lite tool to make systemd work in any container(Windows Subsystem for Linux 2, Docker, Podman, etc.)

Angea Naming from hydrangea(アジサイ) A lite tool to make systemd work in any container(Windows Subsystem for Linux 2, Docker, Podman, etc.) WSL1 is not s

A lite tool to make systemd work in any container(Windows Subsystem for Linux 2, Docker, Podman, etc.)

Angea Naming from hydrangea(アジサイ) A lite tool to make systemd work in any container(Windows Subsystem for Linux 2, Docker, Podman, etc.) WSL1 is not s

A tool for defining and running multi-container Docker applications
A tool for defining and running multi-container Docker applications

Ikki Ikki is a tool for defining and running multi-container Docker applications. It is similar to Docker Compose but comes with some differences. Goa

A container image builder tool for OCI (distrobox/toolbox, also podman/docker)

Distrobox Boost A container image builder tool for Open Container Initiative (distrobox/toolbox, also podman/docker). Distrobox is good enough in runn

A docker credential helper for Azure Container Registries (ACRs)

docker-credential-acr-login A docker credential helper for Azure Container Registries (ACRs). This allows you to automatically log into Azure Containe

docker-rust — the official Rust Docker image

About this Repo This is the Git repo of the Docker official image for rust. See the Docker Hub page for the full readme on how to use this Docker imag

Build tool for custom setups of docker containers. Docker compose didn't offer enough, Kubernetes offered too much. Carbon is the in-between.
Build tool for custom setups of docker containers. Docker compose didn't offer enough, Kubernetes offered too much. Carbon is the in-between.

docker abstraction layer with added flair Fast travel: Tips Contributing How it works Installation Help This tool started its life as a way to make de

Evaluate performance gains to expect when EVM were to compile hot contracts into machine code

Convert evm bytecode to native machine code and go vroom - just an experiment, probably broken, reach out to [email protected] to contribute / productionize.

A simple, plug-and-play Rust-implementation of D3vd/Meme_API

🌃 Rua A simplified Rust-implementation of D3vd/Meme_API. You can self-host this with ease through Docker, but you can also opt to use our free servic

A Zenoh plug-in for ROS2 with a DDS RMW.
A Zenoh plug-in for ROS2 with a DDS RMW.

zplugin-ros2dds A new Zenoh bridge for ROS2. ⚠️ Work in progress... ⚠️ How to install it No version has been released yet. Therefore only nightly buil

Meta framework. Support for dynamic plug-ins and AOP

Kokoro Dynamic publish-subscribe pattern framework. Support for dynamic plug-ins and AOP Not yet stable, do not use in production !! 下面的内容有些老旧了,但是 exa

Owner
lowRISC
Collaborative engineering for open source silicon
lowRISC
A lite tool to make systemd work in any container(Windows Subsystem for Linux 2, Docker, Podman, etc.)

Angea Naming from hydrangea(アジサイ) A lite tool to make systemd work in any container(Windows Subsystem for Linux 2, Docker, Podman, etc.) WSL1 is not s

いんしさくら 16 Dec 5, 2022
docker-rust — the official Rust Docker image

About this Repo This is the Git repo of the Docker official image for rust. See the Docker Hub page for the full readme on how to use this Docker imag

The Rust Programming Language 321 Dec 11, 2022
A tiny minimal container runtime written in Rust.

vas-quod A tiny minimal container runtime written in Rust. The idea is to support a minimal isolated containers without using existing runtimes, vas-q

flouthoc 438 Dec 26, 2022
A secure container runtime with OCI interface

Quark Container Welcome to Quark Container. This repository is the home of Quark Containers code. What's Quark Container Quark Container is high perfo

null 175 Dec 29, 2022
Easy to use, extendable, OCI-compliant container runtime written in pure Rust

PURA - Lightweight & OCI-compliant container runtime Pura is an experimental Linux container runtime written in pure and dependency-minimal Rust. The

Branimir Malesevic 73 Jan 9, 2023
Container monitor in Rust

Conmon-rs A pod level OCI container runtime monitor. The goal of this project is to provide a container monitor in Rust. The scope of conmon-rs encomp

Containers 84 Dec 21, 2022
insject is a tool for poking at containers. It enables you to run an arbitrary command in a container or any mix of Linux namespaces.

Insject insject is a tool for poking at containers. It enables you to run an arbitrary command in a container or any mix of Linux namespaces. It suppo

NCC Group Plc 44 Nov 9, 2022
dedock is a container runtime, with a particular focus on enabling embedded software development across all platforms

dedock is a container runtime, with a particular focus on enabling embedded software development across all platforms. It supports native "containers" on both Linux and macOS.

Daniel Mangum 12 May 27, 2023
Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.

rust-musl-builder: Docker container for easily building static Rust binaries Source on GitHub Changelog UPDATED: Major updates in this release which m

Eric Kidd 1.3k Jan 1, 2023
Very small rust docker image

mini-docker-rust Very small rust docker image. This is an example project on how to build very small docker images for a rust project. The resulting i

null 155 Jan 1, 2023