@@ -33,6 +33,7 @@ import (
33
33
volume_api "github.com/docker/docker/api/types/volume"
34
34
"github.com/docker/docker/errdefs"
35
35
"github.com/docker/go-connections/nat"
36
+ "github.com/docker/go-units"
36
37
"github.com/pkg/errors"
37
38
"github.com/sirupsen/logrus"
38
39
@@ -272,6 +273,31 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
272
273
return nil , nil , nil , err
273
274
}
274
275
276
+ shmSize := int64 (0 )
277
+ if service .ShmSize != "" {
278
+ shmSize , err = strconv .ParseInt (service .ShmSize , 10 , 64 )
279
+ if err != nil {
280
+ return nil , nil , nil , err
281
+ }
282
+ }
283
+
284
+ tmpfs := map [string ]string {}
285
+ for _ , t := range service .Tmpfs {
286
+ if arr := strings .SplitN (t , ":" , 2 ); len (arr ) > 1 {
287
+ tmpfs [arr [0 ]] = arr [1 ]
288
+ } else {
289
+ tmpfs [arr [0 ]] = ""
290
+ }
291
+ }
292
+
293
+ var logConfig container.LogConfig
294
+ if service .Logging != nil {
295
+ logConfig = container.LogConfig {
296
+ Type : service .Logging .Driver ,
297
+ Config : service .Logging .Options ,
298
+ }
299
+ }
300
+
275
301
hostConfig := container.HostConfig {
276
302
AutoRemove : autoRemove ,
277
303
Binds : binds ,
@@ -282,20 +308,23 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
282
308
Init : service .Init ,
283
309
ReadonlyRootfs : service .ReadOnly ,
284
310
RestartPolicy : getRestartPolicy (service ),
285
- // ShmSize: , TODO
286
- Sysctls : service .Sysctls ,
287
- PortBindings : portBindings ,
288
- Resources : resources ,
289
- VolumeDriver : service .VolumeDriver ,
290
- VolumesFrom : service .VolumesFrom ,
291
- DNS : service .DNS ,
292
- DNSSearch : service .DNSSearch ,
293
- DNSOptions : service .DNSOpts ,
294
- ExtraHosts : service .ExtraHosts ,
295
- SecurityOpt : service .SecurityOpt ,
296
- UsernsMode : container .UsernsMode (service .UserNSMode ),
297
- Privileged : service .Privileged ,
298
- Isolation : container .Isolation (service .Isolation ),
311
+ ShmSize : shmSize ,
312
+ Sysctls : service .Sysctls ,
313
+ PortBindings : portBindings ,
314
+ Resources : resources ,
315
+ VolumeDriver : service .VolumeDriver ,
316
+ VolumesFrom : service .VolumesFrom ,
317
+ DNS : service .DNS ,
318
+ DNSSearch : service .DNSSearch ,
319
+ DNSOptions : service .DNSOpts ,
320
+ ExtraHosts : service .ExtraHosts ,
321
+ SecurityOpt : service .SecurityOpt ,
322
+ UsernsMode : container .UsernsMode (service .UserNSMode ),
323
+ Privileged : service .Privileged ,
324
+ PidMode : container .PidMode (service .Pid ),
325
+ Tmpfs : tmpfs ,
326
+ Isolation : container .Isolation (service .Isolation ),
327
+ LogConfig : logConfig ,
299
328
}
300
329
301
330
networkConfig := buildDefaultNetworkConfig (service , networkMode , getContainerName (p .Name , service , number ))
@@ -349,6 +378,37 @@ func getDeployResources(s types.ServiceConfig) container.Resources {
349
378
Driver : device .Driver ,
350
379
})
351
380
}
381
+
382
+ for _ , device := range s .Devices {
383
+ // FIXME should use docker/cli parseDevice, unfortunately private
384
+ src := ""
385
+ dst := ""
386
+ permissions := "rwm"
387
+ arr := strings .Split (device , ":" )
388
+ switch len (arr ) {
389
+ case 3 :
390
+ permissions = arr [2 ]
391
+ fallthrough
392
+ case 2 :
393
+ dst = arr [1 ]
394
+ fallthrough
395
+ case 1 :
396
+ src = arr [0 ]
397
+ }
398
+ resources .Devices = append (resources .Devices , container.DeviceMapping {
399
+ PathOnHost : src ,
400
+ PathInContainer : dst ,
401
+ CgroupPermissions : permissions ,
402
+ })
403
+ }
404
+
405
+ for name , u := range s .Ulimits {
406
+ resources .Ulimits = append (resources .Ulimits , & units.Ulimit {
407
+ Name : name ,
408
+ Hard : int64 (u .Hard ),
409
+ Soft : int64 (u .Soft ),
410
+ })
411
+ }
352
412
return resources
353
413
}
354
414
0 commit comments