Module 13 · Lesson 85 of 98

Container permissions and edge orchestration

Diagnose GPU device access, configure a GPU service in Docker Compose, and choose how to deploy and recover that service on an edge fleet.

  • Beginner to advanced
  • 8 min read
  • 20 min lab
What you will need

Ubuntu 24.04 in WSL2 or a VM for inspection and Compose validation, with Docker Engine and the Compose plugin. A live CUDA test needs a supported NVIDIA GPU, a working host driver, NVIDIA Container Toolkit configured for Docker, and a compatible service image.

Your place in the module
By the end you can 4 objectives
  • Compare a device node's numeric group with the credentials of a container process.
  • Configure and validate a Compose service that requests one NVIDIA GPU.
  • Distinguish container startup, application readiness, and fleet release success.
  • Identify the writable paths and device access a GPU service needs.
Video coming soonContainer permissions and edge orchestration
The video for this lesson is being recorded. Read the lesson below in the meantime.
Recall first from Building a CUDA image and pulling from NGC
  • NGC image tags describe particular software releases, and ARM64 architecture alone does not establish Jetson compatibility.
  • A Dockerfile can extend a compatible TensorRT base with only the files needed for deployment.
  • A multi-stage build can leave headers, compilers, and build artifacts outside the final image.
01

Who can open the GPU device?

3 min read

You have an image. This lesson answers how permissions work inside the container and how to orchestrate it on an edge device.

A device node can appear in a directory listing while open() fails with EACCES. A GPU service can therefore start and list a device path, yet fail as soon as it initializes the GPU. The requested access matters too. A successful read-only open establishes permission for that access mode. A driver client that opens the same node for reading and writing needs both permissions. See open(2).

On a native Ubuntu host, the kernel reports devices to userspace, and udev can apply rules that set device node ownership, group, and mode. Local administrator rules belong in /etc/udev/rules.d/. A rule should match the intended device and grant access to a group assigned to the service. A mode of 0660 gives the owner and group read and write access. Manual changes with chmod or chgrp can disappear when the node is recreated. A persistent rule lets the host apply the same policy after reboot or device reattachment.

Inspect a node on an Ubuntu host with a DRM GPU driver that exposes a render node. Substitute the actual path on your machine. This example illustrates Linux permissions. The Compose service in the next section requests NVIDIA devices through the NVIDIA runtime integration.

bash
node=/dev/dri/renderD128
stat -c 'mode=%a uid=%u gid=%g path=%n' "$node"
udevadm info --query=property --name="$node"
id

stat reports the node's numeric owner and group. udevadm info shows properties that help identify the device when examining rules. id reports the credentials of your current shell. On a device without that render node, inspect the node your installed driver actually exposes. WSL2 may expose GPU access through a different interface. A Raspberry Pi render node can illustrate the permission check when present. The NVIDIA Compose example requires a supported NVIDIA GPU.

For a rootful Docker deployment without user namespace remapping, compare the node's numeric GID with the container process's primary and supplementary GIDs. The group name inside the image can differ from the host name, or the image may have no name for that GID. Linux compares the numeric credentials. Compose can supply a supplementary GID through group_add. Changing the image's group database alone leaves a running process's credentials unchanged. Recreate the service after changing its Compose group settings. See credentials(7).

Opening a device from a containerExposedevice nodeCheckaccesspermissionsMode andprocesscredentialsApplydevicepolicyAlloweddevice andaccessReachdriverExposedevice nodeCheckaccesspermissionsMode andprocesscredentialsApplydevicepolicyAlloweddevice andaccessReachdriver
A service needs a visible device node, permission for the requested access, and approval from device policy.

When diagnosing a failure, check whether the expected node exists inside the container first. Then compare its mode and GID with the service's credentials. If the image includes id, docker compose exec inference id shows the identity of a new exec process. An entrypoint can change the main application's credentials, so inspect the application's process when it does. If the file permissions look right, inspect runtime device selection and policy next. If opening succeeds but initialization fails, use the application's driver error and logs to continue the diagnosis.

02

Run the GPU service with Compose

3 min read

Compose defines the services that run together on one host. This example assumes a CUDA service image whose default command runs in the foreground. The image includes an executable /usr/local/bin/gpu-ready probe and supports running as UID and primary GID 10001. The probe should return zero when the running instance has initialized its GPU and loaded its model, and return a nonzero status while the instance cannot serve requests. It can query a local readiness endpoint that the app updates after initialization.

yaml
services:
  inference:
    image: "${INFERENCE_IMAGE:?set INFERENCE_IMAGE}"
    user: "10001:10001"
    restart: unless-stopped
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]
    healthcheck:
      test: ["CMD", "/usr/local/bin/gpu-ready"]
      interval: 10s
      timeout: 3s
      retries: 3
      start_period: 30s

Set INFERENCE_IMAGE to the reference for your compatible image. The device reservation asks Docker for one NVIDIA GPU and requires capabilities: [gpu]. For a specific GPU, use device_ids in place of count. The engine must support the device request, and its NVIDIA integration must be configured on the target. A GPU request selects a device for access. It does not reserve all of that GPU's memory for the service.

If the required nodes grant access through a host group, add group_add: ["${GPU_DEVICE_GID:?set GPU_DEVICE_GID}"] under inference, using the GID you inspected. Supply each required GID if the nodes use several groups. Some installations already grant the configured user sufficient access through the node modes. Inspect the target rather than copying a group ID from another device. Also check that the image's application files and any mounted data directories are accessible to the configured UID.

bash
docker compose config
docker compose up -d
docker compose ps
docker compose logs --tail=50 inference

config resolves variables and validates the Compose definition. This step works without a GPU. up -d creates and starts the service in the background on the configured engine. Run it on the GPU target when validating hardware access. ps shows container state and health, while logs can show whether the service made it through driver initialization and model loading. Follow those checks with a real inference request so you know the service can return a result.

From Compose file to inferenceValidatedefinitionStartcontainerProbeapplicationreadinessVerifyinferenceresultValidatedefinitionStartcontainerProbeapplicationreadinessVerifyinferenceresult
Configuration validation, container startup, application readiness, and a successful request are separate checks.

The example health check timings are starting values. Set them from startup measurements on the target. start_period gives initialization time before probe failures count toward the retry threshold. Docker records an unhealthy state after enough counted failures. The restart policy reacts to container exit, so a process that stays alive and unhealthy can remain in that state. If a second Compose service must wait, give it a depends_on entry for inference with condition: service_healthy. The dependent service still needs to handle failures that occur after startup.

Going deeperExplore the mechanism

A non-root service identity and rootless Docker are distinct settings. With rootless Docker, the daemon and its containers run without host root privileges. A user namespace maps container UIDs and GIDs to host IDs. The same numeric GID written inside and outside the namespace can therefore refer to different credentials. Inspect the mappings and confirm that the chosen runtime can present the nodes and give the application effective access. See user_namespaces(7).

For least privilege, expose the devices the service needs and keep its host mounts narrow. File mode checks still apply alongside device cgroup policy. On cgroup v2, device filtering is implemented using a cgroup BPF program. Its rules can distinguish character and block devices, major and minor numbers, and read, write, or node-creation access. The runtime normally establishes this policy from its device configuration. Compose device_cgroup_rules can add permissions on a runtime that supports them. Adding a rule supplies neither a visible node nor suitable file credentials. In rootless deployments, a runtime may lack permission to attach or alter the device filter. Use a GPU runtime configuration supported for that setup and account for any device restrictions it delegates to the host. See the kernel cgroup v2 device controller documentation.

03

Deploy and recover on the edge

3 min read

Start with a release that works on a single target. Record the image digest, configuration, compatible host driver, and the test request that proves readiness. On a fleet, group targets by hardware and host software so a release goes to devices with the expected GPU and driver. Deploy to a small group first and confirm that those devices can still serve useful results after a reboot. Keep the previous compatible release identifiable, including the model files and configuration it expects.

With balena, describe the application services in a Compose-based fleet release and use the device supervisor to manage their lifecycle. Check that the target's balenaOS and container engine support the GPU configuration you intend to use. A Compose file validated on Ubuntu establishes how that local Compose installation interprets it. Verify platform-specific service settings and hardware access on a fleet device before promoting the release.

With Mender, choose the update scope. A compatible system image and device integration can use an A/B root filesystem update when the host OS or GPU driver needs to change. An application update can use a suitable Update Module to install and activate a container deployment on the existing host. For that path, define how activation is verified and how the previous release is restored. Rollback behavior depends on the update mechanism and integration. In either deployment, check application readiness locally, including when a device reboots without network access. A remote deployment status alone cannot establish that the model is ready.

Staged edge deploymentRecordreleaseDeploysmall groupReboot andtestExpandrolloutExit from step 3: test failsRestore compatible releaseRecordreleaseDeploysmall groupReboot andtestExpandrolloutExit from step 3: test failsRestore compatible release
Test a release on representative devices and use an inference result to decide whether to expand the rollout.
Going deeperExplore the mechanism

Measure time to the first successful request from power-on and from a service restart. A cold boot includes host and engine startup, device discovery, GPU initialization, and model loading. An update may add image download and extraction. Preloading a verified image removes the need to fetch it during an offline boot, but retaining both current and previous releases costs storage. Persisting a generated cache can reduce later startup work. Give it a specific writable directory and ensure the service can recognise a cache from an incompatible release.

Compose read_only: true makes the container root filesystem read-only. Give temporary files an explicit writable tmpfs mount such as /tmp if the service needs it, and use a dedicated volume for data that must survive restarts. A tmpfs consumes memory as files accumulate, which matters on an embedded device. Send logs to standard output and standard error if the service supports it. Test startup with empty volumes as well as existing state, since first-run directory creation or cache generation may reveal writes that a warm restart misses. A read-only root filesystem limits where a compromised process can persist changes. Writable volumes and exposed devices retain their own permissions.

The next lesson, Designing the pipeline and its zero-copy data flow, starts the capstone: it takes a packaged, deployable GPU service like this one and designs the camera-to-detection pipeline that runs inside it.

Key takeaways

  • Host udev rules can set device ownership and mode, and Linux checks numeric credentials when a process opens a node.
  • Compose can request a GPU, assign a service identity, and probe application health.
  • Rootless Docker still depends on host-granted device access and compatible runtime configuration.
  • A read-only container root filesystem can coexist with explicit writable mounts.
Reflect
  1. Explain to a colleague, in two sentences: compare a device node's numeric group with the credentials of a container process.
  2. Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
  3. What surprised you when you ran the commands yourself?
On a real board

Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.

References and further reading

Find your next step

↑ ↓ to move · Enter to open · Esc to close