File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed
inspecttypes/dockercompat Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -773,7 +773,18 @@ func withInternalLabels(internalLabels internalLabels) (containerd.NewContainerO
773773 }
774774
775775 if len (internalLabels .deviceMapping ) > 0 {
776- hostConfigLabel .DeviceMapping = internalLabels .deviceMapping
776+ for i := range internalLabels .deviceMapping {
777+ var deviceMapping dockercompat.DeviceMapping
778+ device := internalLabels .deviceMapping [i ]
779+ devPath , conPath , mode , err := ParseDevice (device )
780+ if err != nil {
781+ return nil , err
782+ }
783+ deviceMapping .CgroupPermissions = mode
784+ deviceMapping .PathInContainer = conPath
785+ deviceMapping .PathOnHost = devPath
786+ hostConfigLabel .Devices = append (hostConfigLabel .Devices , deviceMapping )
787+ }
777788 }
778789
779790 hostConfigJSON , err := json .Marshal (hostConfigLabel )
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ type HostConfig struct {
162162 ShmSize int64 // Size of /dev/shm in bytes. The size must be greater than 0.
163163 Sysctls map [string ]string // List of Namespaced sysctls used for the container
164164 Runtime string // Runtime to use with this container
165- Devices []string // List of devices to map inside the container
165+ Devices []DeviceMapping // List of devices to map inside the container
166166 PidMode string // PID namespace to use for the container
167167 Tmpfs map [string ]string `json:"Tmpfs,omitempty"` // List of tmpfs (mounts) used for the container
168168}
@@ -239,9 +239,15 @@ type DNSSettings struct {
239239}
240240
241241type HostConfigLabel struct {
242- BlkioWeight uint16
243- CidFile string
244- DeviceMapping []string
242+ BlkioWeight uint16
243+ CidFile string
244+ Devices []DeviceMapping
245+ }
246+
247+ type DeviceMapping struct {
248+ PathOnHost string
249+ PathInContainer string
250+ CgroupPermissions string
245251}
246252
247253type CPUSettings struct {
@@ -485,7 +491,7 @@ func ContainerFromNative(n *native.Container) (*Container, error) {
485491 }
486492 c .Config .Hostname = hostname
487493
488- c .HostConfig .Devices = hostConfigLabel .DeviceMapping
494+ c .HostConfig .Devices = hostConfigLabel .Devices
489495
490496 var pidMode string
491497 if n .Labels [labels .PIDContainer ] != "" {
You can’t perform that action at this time.
0 commit comments