3

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?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
OlavT
  • 2,496
  • 4
  • 31
  • 56

1 Answers1

11

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 privilege the container completely opening up everything on the hardware side. To do this you just use the Privileged parameter. Note there is only one d in Privileged.

{
  "HostConfig": {
    "Privileged": true
  }
}
tourdownunder
  • 1,779
  • 4
  • 22
  • 34
Dariusz Parys
  • 161
  • 1
  • 6
  • I get this error for the device: "500 - One or more errors occurred. (Docker API responded with status code=InternalServerError, response={"message":"OCI runtime create failed: device access at 8 field cannot be empty: unknown"})". Is there a log with more details? – OlavT Dec 19 '17 at 06:47
  • I assume that is running on raspbian, right? What version of docker are you running? – Dariusz Parys Dec 19 '17 at 07:57
  • I just tried it today and realized that the Azure Portal setting the createOptions is flaky, somehow it doesn't store the values you specify when setting modules. As a workaround (as this is still preview) I suggest that you use a deployment script for updating the deployment manifest. Here is a [github repository](https://github.com/jonbgallant/azure-iot-edge-config) you can use for that matter. That should fix the problem – Dariusz Parys Dec 20 '17 at 14:49
  • 1
    Your original answer is partly correct. If you add "CgroupPermissions": "rwm" to the JSON it works. – OlavT Jan 12 '18 at 11:02