Option to configure cgroup manager (adds --exec-opt)
| ... | ... |
@@ -51,6 +51,7 @@ complete -c docker -f -n '__fish_docker_no_subcommand' -s d -l daemon -d 'Enable |
| 51 | 51 |
complete -c docker -f -n '__fish_docker_no_subcommand' -l dns -d 'Force Docker to use specific DNS servers' |
| 52 | 52 |
complete -c docker -f -n '__fish_docker_no_subcommand' -l dns-search -d 'Force Docker to use specific DNS search domains' |
| 53 | 53 |
complete -c docker -f -n '__fish_docker_no_subcommand' -s e -l exec-driver -d 'Force the Docker runtime to use a specific exec driver' |
| 54 |
+complete -c docker -f -n '__fish_docker_no_subcommand' -l exec-opt -d 'Set exec driver options' |
|
| 54 | 55 |
complete -c docker -f -n '__fish_docker_no_subcommand' -l fixed-cidr -d 'IPv4 subnet for fixed IPs (e.g. 10.20.0.0/16)' |
| 55 | 56 |
complete -c docker -f -n '__fish_docker_no_subcommand' -l fixed-cidr-v6 -d 'IPv6 subnet for fixed IPs (e.g.: 2001:a02b/48)' |
| 56 | 57 |
complete -c docker -f -n '__fish_docker_no_subcommand' -s G -l group -d 'Group to assign the unix socket specified by -H when running in daemon mode' |
| ... | ... |
@@ -29,6 +29,7 @@ type Config struct {
|
| 29 | 29 |
GraphDriver string |
| 30 | 30 |
GraphOptions []string |
| 31 | 31 |
ExecDriver string |
| 32 |
+ ExecOptions []string |
|
| 32 | 33 |
Mtu int |
| 33 | 34 |
SocketGroup string |
| 34 | 35 |
EnableCors bool |
| ... | ... |
@@ -70,6 +71,7 @@ func (config *Config) InstallFlags() {
|
| 70 | 70 |
flag.StringVar(&config.CorsHeaders, []string{"-api-cors-header"}, "", "Set CORS headers in the remote API")
|
| 71 | 71 |
opts.IPVar(&config.Bridge.DefaultIp, []string{"#ip", "-ip"}, "0.0.0.0", "Default IP when binding container ports")
|
| 72 | 72 |
opts.ListVar(&config.GraphOptions, []string{"-storage-opt"}, "Set storage driver options")
|
| 73 |
+ opts.ListVar(&config.ExecOptions, []string{"-exec-opt"}, "Set exec driver options")
|
|
| 73 | 74 |
// FIXME: why the inconsistency between "hosts" and "sockets"? |
| 74 | 75 |
opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "DNS server to use")
|
| 75 | 76 |
opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "DNS search domains to use")
|
| ... | ... |
@@ -942,7 +942,7 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine, registryService |
| 942 | 942 |
|
| 943 | 943 |
sysInfo := sysinfo.New(false) |
| 944 | 944 |
const runDir = "/var/run/docker" |
| 945 |
- ed, err := execdrivers.NewDriver(config.ExecDriver, runDir, config.Root, sysInitPath, sysInfo) |
|
| 945 |
+ ed, err := execdrivers.NewDriver(config.ExecDriver, config.ExecOptions, runDir, config.Root, sysInitPath, sysInfo) |
|
| 946 | 946 |
if err != nil {
|
| 947 | 947 |
return nil, err |
| 948 | 948 |
} |
| ... | ... |
@@ -10,7 +10,7 @@ import ( |
| 10 | 10 |
"github.com/docker/docker/pkg/sysinfo" |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 |
-func NewDriver(name, root, libPath, initPath string, sysInfo *sysinfo.SysInfo) (execdriver.Driver, error) {
|
|
| 13 |
+func NewDriver(name string, options []string, root, libPath, initPath string, sysInfo *sysinfo.SysInfo) (execdriver.Driver, error) {
|
|
| 14 | 14 |
switch name {
|
| 15 | 15 |
case "lxc": |
| 16 | 16 |
// we want to give the lxc driver the full docker root because it needs |
| ... | ... |
@@ -18,7 +18,7 @@ func NewDriver(name, root, libPath, initPath string, sysInfo *sysinfo.SysInfo) ( |
| 18 | 18 |
// to be backwards compatible |
| 19 | 19 |
return lxc.NewDriver(root, libPath, initPath, sysInfo.AppArmor) |
| 20 | 20 |
case "native": |
| 21 |
- return native.NewDriver(path.Join(root, "execdriver", "native"), initPath) |
|
| 21 |
+ return native.NewDriver(path.Join(root, "execdriver", "native"), initPath, options) |
|
| 22 | 22 |
} |
| 23 | 23 |
return nil, fmt.Errorf("unknown exec driver %s", name)
|
| 24 | 24 |
} |
| ... | ... |
@@ -8,12 +8,14 @@ import ( |
| 8 | 8 |
"os" |
| 9 | 9 |
"os/exec" |
| 10 | 10 |
"path/filepath" |
| 11 |
+ "strings" |
|
| 11 | 12 |
"sync" |
| 12 | 13 |
"syscall" |
| 13 | 14 |
"time" |
| 14 | 15 |
|
| 15 | 16 |
"github.com/Sirupsen/logrus" |
| 16 | 17 |
"github.com/docker/docker/daemon/execdriver" |
| 18 |
+ "github.com/docker/docker/pkg/parsers" |
|
| 17 | 19 |
"github.com/docker/docker/pkg/reexec" |
| 18 | 20 |
sysinfo "github.com/docker/docker/pkg/system" |
| 19 | 21 |
"github.com/docker/docker/pkg/term" |
| ... | ... |
@@ -39,7 +41,7 @@ type driver struct {
|
| 39 | 39 |
sync.Mutex |
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 |
-func NewDriver(root, initPath string) (*driver, error) {
|
|
| 42 |
+func NewDriver(root, initPath string, options []string) (*driver, error) {
|
|
| 43 | 43 |
meminfo, err := sysinfo.ReadMemInfo() |
| 44 | 44 |
if err != nil {
|
| 45 | 45 |
return nil, err |
| ... | ... |
@@ -52,11 +54,45 @@ func NewDriver(root, initPath string) (*driver, error) {
|
| 52 | 52 |
if err := apparmor.InstallDefaultProfile(); err != nil {
|
| 53 | 53 |
return nil, err |
| 54 | 54 |
} |
| 55 |
+ |
|
| 56 |
+ // choose cgroup manager |
|
| 57 |
+ // this makes sure there are no breaking changes to people |
|
| 58 |
+ // who upgrade from versions without native.cgroupdriver opt |
|
| 55 | 59 |
cgm := libcontainer.Cgroupfs |
| 56 | 60 |
if systemd.UseSystemd() {
|
| 57 | 61 |
cgm = libcontainer.SystemdCgroups |
| 58 | 62 |
} |
| 59 | 63 |
|
| 64 |
+ // parse the options |
|
| 65 |
+ for _, option := range options {
|
|
| 66 |
+ key, val, err := parsers.ParseKeyValueOpt(option) |
|
| 67 |
+ if err != nil {
|
|
| 68 |
+ return nil, err |
|
| 69 |
+ } |
|
| 70 |
+ key = strings.ToLower(key) |
|
| 71 |
+ switch key {
|
|
| 72 |
+ case "native.cgroupdriver": |
|
| 73 |
+ // override the default if they set options |
|
| 74 |
+ switch val {
|
|
| 75 |
+ case "systemd": |
|
| 76 |
+ if systemd.UseSystemd() {
|
|
| 77 |
+ cgm = libcontainer.SystemdCgroups |
|
| 78 |
+ } else {
|
|
| 79 |
+ // warn them that they chose the wrong driver |
|
| 80 |
+ logrus.Warn("You cannot use systemd as native.cgroupdriver, using cgroupfs instead")
|
|
| 81 |
+ } |
|
| 82 |
+ case "cgroupfs": |
|
| 83 |
+ cgm = libcontainer.Cgroupfs |
|
| 84 |
+ default: |
|
| 85 |
+ return nil, fmt.Errorf("Unknown native.cgroupdriver given %q. try cgroupfs or systemd", val)
|
|
| 86 |
+ } |
|
| 87 |
+ default: |
|
| 88 |
+ return nil, fmt.Errorf("Unknown option %s\n", key)
|
|
| 89 |
+ } |
|
| 90 |
+ } |
|
| 91 |
+ |
|
| 92 |
+ logrus.Debugf("Using %v as native.cgroupdriver", cgm)
|
|
| 93 |
+ |
|
| 60 | 94 |
f, err := libcontainer.New( |
| 61 | 95 |
root, |
| 62 | 96 |
cgm, |
| ... | ... |
@@ -124,6 +124,9 @@ unix://[/path/to/socket] to use. |
| 124 | 124 |
**-v**, **--version**=*true*|*false* |
| 125 | 125 |
Print version information and quit. Default is false. |
| 126 | 126 |
|
| 127 |
+**--exec-opt**=[] |
|
| 128 |
+ Set exec driver options. See EXEC DRIVER OPTIONS. |
|
| 129 |
+ |
|
| 127 | 130 |
**--selinux-enabled**=*true*|*false* |
| 128 | 131 |
Enable selinux support. Default is false. SELinux does not presently support the BTRFS storage driver. |
| 129 | 132 |
|
| ... | ... |
@@ -357,6 +360,18 @@ for data and metadata: |
| 357 | 357 |
--storage-opt dm.metadatadev=/dev/vdc \ |
| 358 | 358 |
--storage-opt dm.basesize=20G |
| 359 | 359 |
|
| 360 |
+# EXEC DRIVER OPTIONS |
|
| 361 |
+ |
|
| 362 |
+Use the **--exec-opt** flags to specify options to the exec-driver. The only |
|
| 363 |
+driver that accepts this flag is the *native* (libcontainer) driver. As a |
|
| 364 |
+result, you must also specify **-s=**native for this option to have effect. The |
|
| 365 |
+following is the only *native* option: |
|
| 366 |
+ |
|
| 367 |
+#### native.cgroupdriver |
|
| 368 |
+Specifies the management of the container's `cgroups`. You can specify |
|
| 369 |
+`cgroupfs` or `systemd`. If you specify `systemd` and it is not available, the |
|
| 370 |
+system uses `cgroupfs`. |
|
| 371 |
+ |
|
| 360 | 372 |
#### Client |
| 361 | 373 |
For specific client examples please see the man page for the specific Docker |
| 362 | 374 |
command. For example: |
| ... | ... |
@@ -442,7 +442,7 @@ Currently supported options are: |
| 442 | 442 |
> Otherwise, set this flag for migrating existing Docker daemons to a |
| 443 | 443 |
> daemon with a supported environment. |
| 444 | 444 |
|
| 445 |
-### Docker exec-driver option |
|
| 445 |
+### Docker execdriver option |
|
| 446 | 446 |
|
| 447 | 447 |
The Docker daemon uses a specifically built `libcontainer` execution driver as its |
| 448 | 448 |
interface to the Linux kernel `namespaces`, `cgroups`, and `SELinux`. |
| ... | ... |
@@ -452,6 +452,21 @@ https://linuxcontainers.org/) via the `lxc` execution driver, however, this is |
| 452 | 452 |
not where the primary development of new functionality is taking place. |
| 453 | 453 |
Add `-e lxc` to the daemon flags to use the `lxc` execution driver. |
| 454 | 454 |
|
| 455 |
+#### Options for the native execdriver |
|
| 456 |
+ |
|
| 457 |
+You can configure the `native` (libcontainer) execdriver using options specified |
|
| 458 |
+with the `--exec-opt` flag. All the flag's options have the `native` prefix. A |
|
| 459 |
+single `native.cgroupdriver` option is available. |
|
| 460 |
+ |
|
| 461 |
+The `native.cgroupdriver` option specifies the management of the container's |
|
| 462 |
+cgroups. You can specify `cgroupfs` or `systemd`. If you specify `systemd` and |
|
| 463 |
+it is not available, the system uses `cgroupfs`. By default, if no option is |
|
| 464 |
+specified, the execdriver first tries `systemd` and falls back to `cgroupfs`. |
|
| 465 |
+This example sets the execdriver to `cgroupfs`: |
|
| 466 |
+ |
|
| 467 |
+ $ sudo docker -d --exec-opt native.cgroupdriver=cgroupfs |
|
| 468 |
+ |
|
| 469 |
+Setting this option applies to all containers the daemon launches. |
|
| 455 | 470 |
|
| 456 | 471 |
### Daemon DNS options |
| 457 | 472 |
|