Skip to content

feat: expose container devices to templates#757

Open
JamBalaya56562 wants to merge 1 commit into
nginx-proxy:mainfrom
JamBalaya56562:feat/277-device-passthrough
Open

feat: expose container devices to templates#757
JamBalaya56562 wants to merge 1 commit into
nginx-proxy:mainfrom
JamBalaya56562:feat/277-device-passthrough

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Exposes container device passthrough (HostConfig.Devices) to templates, reimplementing the stale PR #277 against the current internal/ layout.

  • Adds a Device{PathOnHost, PathInContainer, Permissions} type and a Devices []Device field on RuntimeContainer.
  • Populates it in getContainers, mirroring the existing Mounts loop. go-dockerclient's Device.CgroupPermissions is mapped to Device.Permissions.

Use case: discovering forwarded device nodes (webcams, USB-serial adapters, etc.) from templates.

Notes

  • The populate loop iterates the nil-safe local copy of HostConfig (introduced in fix: avoid panic on nil container Config/NetworkSettings/HostConfig #748) instead of dereferencing container.HostConfig directly, so a container inspected with a nil HostConfig cannot panic.
  • The unrelated t.Fatalt.Fatalf churn from the original PR is dropped.
  • HostConfig.Devices has been stable in go-dockerclient since 2018, so no dependency change is required.

Tests

Added TestGetContainersDevices, which drives getContainers against a mock daemon returning a device and asserts the populated Devices. Documented the Device struct and a JSON example in the README.

Reimplements #277

@JamBalaya56562 JamBalaya56562 force-pushed the feat/277-device-passthrough branch from e1c6fe6 to 4b5e1bc Compare July 11, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant