You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在docker-compose中配置--device-cgroup-rule参数?是否支持?

Does docker-compose support the --device-cgroup-rule option?

Great question! Yes, docker-compose does support configuring the equivalent of the --device-cgroup-rule flag you use with docker run—it just uses a key that’s a bit easy to overlook in the official docs.

Here’s how to set it up:

Suppose your working docker run command looks like this:

docker run --device-cgroup-rule='c 189:* rmw' my-image

You can replicate this in your docker-compose.yml by adding the devices_cgroup_rules field under your service definition, like so:

version: '3.8'
services:
  my-service:
    image: my-image
    devices_cgroup_rules:
      - 'c 189:* rmw'

A quick note on the rule format:

Each rule follows the structure [device-type] [major]:[minor] [permissions], where:

  • device-type is either c (for character devices) or b (for block devices)
  • major and minor are device numbers—use * to match all devices of that type
  • permissions can be any combination of r (read), w (write), and m (mknod)

If you need multiple device cgroup rules, just add additional entries to the devices_cgroup_rules list.

内容的提问来源于stack exchange,提问作者Petr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:53:00