@@ -143,29 +143,30 @@ type Container struct {
143
143
// From https://github.com/moby/moby/blob/8dbd90ec00daa26dc45d7da2431c965dec99e8b4/api/types/container/host_config.go#L391
144
144
// HostConfig the non-portable Config structure of a container.
145
145
type HostConfig struct {
146
- ExtraHosts []string // List of extra hosts
147
- PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host
148
- LogConfig LogConfig // Configuration of the logs for this container
149
- BlkioWeight uint16 // Block IO weight (relative weight vs. other containers)
150
- CPUSetMems string `json:"CpusetMems"` // CpusetMems 0-2, 0,1
151
- CPUSetCPUs string `json:"CpusetCpus"` // CpusetCpus 0-2, 0,1
152
- CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota
153
- CPUShares uint64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers)
154
- ContainerIDFile string // File (path) where the containerId is written
155
- GroupAdd []string // GroupAdd specifies additional groups to join
156
- IpcMode string // IPC namespace to use for the container
157
- CgroupnsMode string // Cgroup namespace mode to use for the container
158
- Memory int64 // Memory limit (in bytes)
159
- MemorySwap int64 // Total memory usage (memory + swap); set `-1` to enable unlimited swap
160
- OomKillDisable bool // specifies whether to disable OOM Killer
161
- DNS []string `json:"Dns"` // List of DNS server to lookup
162
- DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for
163
- DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for
164
- OomScoreAdj int // specifies the tune container’s OOM preferences (-1000 to 1000, rootless: 100 to 1000)
165
- ReadonlyRootfs bool // Is the container root filesystem in read-only
166
- UTSMode string // UTS namespace to use for the container
167
- ShmSize int64 // Size of /dev/shm in bytes. The size must be greater than 0.
168
-
146
+ ExtraHosts []string // List of extra hosts
147
+ PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host
148
+ LogConfig LogConfig // Configuration of the logs for this container
149
+ BlkioWeight uint16 // Block IO weight (relative weight vs. other containers)
150
+ CPUSetMems string `json:"CpusetMems"` // CpusetMems 0-2, 0,1
151
+ CPUSetCPUs string `json:"CpusetCpus"` // CpusetCpus 0-2, 0,1
152
+ CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota
153
+ CPUShares uint64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers)
154
+ ContainerIDFile string // File (path) where the containerId is written
155
+ GroupAdd []string // GroupAdd specifies additional groups to join
156
+ IpcMode string // IPC namespace to use for the container
157
+ CgroupnsMode string // Cgroup namespace mode to use for the container
158
+ Memory int64 // Memory limit (in bytes)
159
+ MemorySwap int64 // Total memory usage (memory + swap); set `-1` to enable unlimited swap
160
+ OomKillDisable bool // specifies whether to disable OOM Killer
161
+ DNS []string `json:"Dns"` // List of DNS server to lookup
162
+ DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for
163
+ DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for
164
+ OomScoreAdj int // specifies the tune container’s OOM preferences (-1000 to 1000, rootless: 100 to 1000)
165
+ ReadonlyRootfs bool // Is the container root filesystem in read-only
166
+ UTSMode string // UTS namespace to use for the container
167
+ ShmSize int64 // Size of /dev/shm in bytes. The size must be greater than 0.
168
+ Sysctls map [string ]string // List of Namespaced sysctls used for the container
169
+ Runtime string // Runtime to use with this container
169
170
}
170
171
171
172
// From https://github.com/moby/moby/blob/v20.10.1/api/types/types.go#L416-L427
@@ -466,6 +467,13 @@ func ContainerFromNative(n *native.Container) (*Container, error) {
466
467
shmSize , _ := getShmSizeFromNative (n .Spec .(* specs.Spec ))
467
468
c .HostConfig .ShmSize = shmSize
468
469
470
+ sysctls , _ := getSysctlFromNative (n .Spec .(* specs.Spec ))
471
+ c .HostConfig .Sysctls = sysctls
472
+
473
+ if n .Runtime .Name != "" {
474
+ c .HostConfig .Runtime = n .Runtime .Name
475
+ }
476
+
469
477
c .State = cs
470
478
c .Config = & Config {
471
479
Labels : n .Labels ,
@@ -789,6 +797,14 @@ func getShmSizeFromNative(sp *specs.Spec) (int64, error) {
789
797
return res , nil
790
798
}
791
799
800
+ func getSysctlFromNative (sp * specs.Spec ) (map [string ]string , error ) {
801
+ var res map [string ]string
802
+ if sp .Linux != nil && sp .Linux .Sysctl != nil {
803
+ res = sp .Linux .Sysctl
804
+ }
805
+ return res , nil
806
+ }
807
+
792
808
type IPAMConfig struct {
793
809
Subnet string `json:"Subnet,omitempty"`
794
810
Gateway string `json:"Gateway,omitempty"`
0 commit comments