2016-06-07 03:45:21 -04:00
|
|
|
// +build !windows
|
|
|
|
|
2016-05-23 17:49:50 -04:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/docker/docker/container"
|
|
|
|
"github.com/docker/docker/libcontainerd"
|
|
|
|
)
|
|
|
|
|
2017-03-27 13:18:53 -04:00
|
|
|
// getLibcontainerdCreateOptions callers must hold a lock on the container
|
2016-10-05 16:29:56 -04:00
|
|
|
func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Container) ([]libcontainerd.CreateOption, error) {
|
2016-05-23 17:49:50 -04:00
|
|
|
createOptions := []libcontainerd.CreateOption{}
|
|
|
|
|
2016-06-20 14:21:01 -04:00
|
|
|
// Ensure a runtime has been assigned to this container
|
|
|
|
if container.HostConfig.Runtime == "" {
|
2017-01-12 14:24:30 -05:00
|
|
|
container.HostConfig.Runtime = daemon.configStore.GetDefaultRuntimeName()
|
2017-03-27 13:18:53 -04:00
|
|
|
container.CheckpointTo(daemon.containersReplica)
|
2016-06-20 14:21:01 -04:00
|
|
|
}
|
|
|
|
|
2016-05-23 17:49:50 -04:00
|
|
|
rt := daemon.configStore.GetRuntime(container.HostConfig.Runtime)
|
|
|
|
if rt == nil {
|
2016-06-20 14:21:01 -04:00
|
|
|
return nil, fmt.Errorf("no such runtime '%s'", container.HostConfig.Runtime)
|
2016-05-23 17:49:50 -04:00
|
|
|
}
|
2016-08-26 09:33:26 -04:00
|
|
|
if UsingSystemd(daemon.configStore) {
|
|
|
|
rt.Args = append(rt.Args, "--systemd-cgroup=true")
|
|
|
|
}
|
2016-05-23 17:49:50 -04:00
|
|
|
createOptions = append(createOptions, libcontainerd.WithRuntime(rt.Path, rt.Args))
|
|
|
|
|
2016-10-05 16:29:56 -04:00
|
|
|
return createOptions, nil
|
2016-05-23 17:49:50 -04:00
|
|
|
}
|