How to specify --device option for Docker run comm

2019-06-11 07:54发布

I'm testing out the new Azure IoT Edge V2. I need to run the Docker image deployed to the edge device with the --device option like this (to access a serial port):

$ docker run --device=/dev/serial/by-id/usb-ELT_SENSOR_EK100_V1.0_SN000001-if00-port0 olavt.azurecr.io/testco2sensor-arm32

How do I specify the --device option when creating the new deployment from the Azure portal?

1条回答
神经病院院长
2楼-- · 2019-06-11 08:24

In theory you can specify anything documented in the docker api container create options stated here https://docs.docker.com/engine/api/v1.30/#operation/ContainerCreate

In the device case you could (I never tried it that way) specify in the createOptions:

{
  "HostConfig": {
    "Devices": [
      {
        "PathOnHost": "/dev/serial/by-id/usb-ELT_SENSOR_EK100_V1.0_SN000001-if00-port0",
        "PathInContainer": "/dev/serial/by-id/usb-ELT_SENSOR_EK100_V1.0_SN000001-if00-port0",
        "CgroupPermissions": "rwm"
      }
    ]
  }
}

What works for sure it to priviledge the container completely opening up everything on the hardware side. To do this you just use the Priviledged parameter

{
  "HostConfig": {
    "Priviledged": true
  }
}
查看更多
登录 后发表回答