2016-05-23 17:49:50 -04:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
2017-08-08 17:21:56 -04:00
|
|
|
"github.com/Microsoft/opengcs/client"
|
2016-05-23 17:49:50 -04:00
|
|
|
"github.com/docker/docker/container"
|
|
|
|
"github.com/docker/docker/libcontainerd"
|
|
|
|
)
|
|
|
|
|
2016-10-05 16:29:56 -04:00
|
|
|
func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Container) ([]libcontainerd.CreateOption, error) {
|
2016-09-16 13:41:47 -04:00
|
|
|
createOptions := []libcontainerd.CreateOption{}
|
2016-09-19 17:47:48 -04:00
|
|
|
|
2017-08-01 14:57:50 -04:00
|
|
|
// LCOW options.
|
|
|
|
if container.Platform == "linux" {
|
|
|
|
config := &client.Config{}
|
|
|
|
if err := config.GenerateDefault(daemon.configStore.GraphOptions); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
// Override from user-supplied options.
|
|
|
|
for k, v := range container.HostConfig.StorageOpt {
|
|
|
|
switch k {
|
|
|
|
case "lcow.kirdpath":
|
|
|
|
config.KirdPath = v
|
|
|
|
case "lcow.kernel":
|
|
|
|
config.KernelFile = v
|
|
|
|
case "lcow.initrd":
|
|
|
|
config.InitrdFile = v
|
|
|
|
case "lcow.vhdx":
|
|
|
|
config.Vhdx = v
|
|
|
|
case "lcow.bootparameters":
|
|
|
|
config.BootParameters = v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := config.Validate(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
lcowOpts := &libcontainerd.LCOWOption{
|
|
|
|
Config: config,
|
|
|
|
}
|
|
|
|
createOptions = append(createOptions, lcowOpts)
|
|
|
|
}
|
|
|
|
|
2016-10-05 16:29:56 -04:00
|
|
|
return createOptions, nil
|
2016-05-23 17:49:50 -04:00
|
|
|
}
|