@@ -117,6 +117,16 @@ func (h *handler) create(w http.ResponseWriter, r *http.Request) {
117117 }
118118 }
119119
120+ // Sysctls:
121+ // Sysctls are passed in as a map of strings,
122+ // but nerdctl expects an array of strings with format [Sysctls1=VALUE1, Sysctls2=VALUE2, ...].
123+ sysctls := []string {}
124+ if req .HostConfig .Sysctls != nil {
125+ for key , val := range req .HostConfig .Sysctls {
126+ sysctls = append (sysctls , fmt .Sprintf ("%s=%s" , key , val ))
127+ }
128+ }
129+
120130 // Environment vars:
121131 env := []string {}
122132 if req .Env != nil {
@@ -141,19 +151,29 @@ func (h *handler) create(w http.ResponseWriter, r *http.Request) {
141151
142152 memoryReservation := ""
143153 if req .HostConfig .MemoryReservation != 0 {
144- memoryReservation = strconv . FormatInt (req .HostConfig .MemoryReservation , 10 )
154+ memoryReservation = fmt . Sprint (req .HostConfig .MemoryReservation )
145155 }
146156
147157 memorySwap := ""
148158 if req .HostConfig .MemorySwap != 0 {
149- memorySwap = strconv . FormatInt (req .HostConfig .MemorySwap , 10 )
159+ memorySwap = fmt . Sprint (req .HostConfig .MemorySwap )
150160 }
151161
152162 memorySwappiness := int64 (- 1 )
153- if req .HostConfig .MemorySwappiness != 0 && req . HostConfig . MemorySwappiness > - 1 {
163+ if req .HostConfig .MemorySwappiness > 0 {
154164 memorySwappiness = req .HostConfig .MemorySwappiness
155165 }
156166
167+ shmSize := ""
168+ if req .HostConfig .ShmSize > 0 {
169+ shmSize = fmt .Sprint (req .HostConfig .ShmSize )
170+ }
171+
172+ runtime := defaults .Runtime
173+ if req .HostConfig .Runtime != "" {
174+ runtime = req .HostConfig .Runtime
175+ }
176+
157177 volumesFrom := []string {}
158178 if req .HostConfig .VolumesFrom != nil {
159179 volumesFrom = req .HostConfig .VolumesFrom
@@ -212,6 +232,7 @@ func (h *handler) create(w http.ResponseWriter, r *http.Request) {
212232 MemoryReservation : memoryReservation , // Memory soft limit (in bytes)
213233 MemorySwap : memorySwap , // Total memory usage (memory + swap); set `-1` to enable unlimited swap
214234 IPC : req .HostConfig .IpcMode , // IPC namespace to use
235+ ShmSize : shmSize , // ShmSize set the size of /dev/shm
215236 // #endregion
216237
217238 // #region for user flags
@@ -227,7 +248,8 @@ func (h *handler) create(w http.ResponseWriter, r *http.Request) {
227248 // #endregion
228249
229250 // #region for runtime flags
230- Runtime : defaults .Runtime , // nerdctl default.
251+ Runtime : runtime , // Runtime to use for this container, e.g. "crun", or "io.containerd.runc.v2".
252+ Sysctl : sysctls , // Sysctl set sysctl options, e.g "net.ipv4.ip_forward=1"
231253 // #endregion
232254
233255 // #region for volume flags
@@ -265,6 +287,7 @@ func (h *handler) create(w http.ResponseWriter, r *http.Request) {
265287
266288 // #region for rootfs flags
267289 ReadOnly : req .HostConfig .ReadonlyRootfs , // Is the container root filesystem in read-only
290+ // #endregion
268291 }
269292
270293 portMappings , err := translatePortMappings (req .HostConfig .PortBindings )
0 commit comments