@@ -10,9 +10,11 @@ import (
1010 "path/filepath"
1111 "strconv"
1212
13+ "github.com/containerd/containerd/linux"
1314 "github.com/docker/docker/cmd/dockerd/hack"
1415 "github.com/docker/docker/daemon"
1516 "github.com/docker/docker/libcontainerd"
17+ "github.com/docker/docker/pkg/parsers/kernel"
1618 "github.com/docker/libnetwork/portallocator"
1719 "golang.org/x/sys/unix"
1820)
@@ -35,42 +37,48 @@ func getDaemonConfDir(_ string) string {
3537 return "/etc/docker"
3638}
3739
38- // setupConfigReloadTrap configures the USR2 signal to reload the configuration.
39- func ( cli * DaemonCli ) setupConfigReloadTrap () {
40- c := make ( chan os. Signal , 1 )
41- signal . Notify ( c , unix . SIGHUP )
42- go func () {
43- for range c {
44- cli . reloadConfig ()
45- }
46- }()
47- }
40+ func ( cli * DaemonCli ) getPlatformRemoteOptions () ([]libcontainerd. RemoteOption , error ) {
41+ // On older kernel, letting putting the containerd-shim in its own
42+ // namespace will effectively prevent operations such as unlink, rename
43+ // and remove on mountpoints that were present at the time the shim
44+ // namespace was created. This would led to a famous EBUSY will trying to
45+ // remove shm mounts.
46+ var noNewNS bool
47+ if ! kernel . CheckKernelVersion ( 3 , 18 , 0 ) {
48+ noNewNS = true
49+ }
4850
49- func (cli * DaemonCli ) getPlatformRemoteOptions () []libcontainerd.RemoteOption {
5051 opts := []libcontainerd.RemoteOption {
51- libcontainerd .WithDebugLog (cli .Config .Debug ),
5252 libcontainerd .WithOOMScore (cli .Config .OOMScoreAdjust ),
53+ libcontainerd .WithPlugin ("linux" , & linux.Config {
54+ Shim : daemon .DefaultShimBinary ,
55+ Runtime : daemon .DefaultRuntimeBinary ,
56+ RuntimeRoot : filepath .Join (cli .Config .Root , "runc" ),
57+ ShimDebug : cli .Config .Debug ,
58+ ShimNoMountNS : noNewNS ,
59+ }),
60+ }
61+ if cli .Config .Debug {
62+ opts = append (opts , libcontainerd .WithLogLevel ("debug" ))
5363 }
5464 if cli .Config .ContainerdAddr != "" {
5565 opts = append (opts , libcontainerd .WithRemoteAddr (cli .Config .ContainerdAddr ))
5666 } else {
5767 opts = append (opts , libcontainerd .WithStartDaemon (true ))
5868 }
59- if daemon .UsingSystemd (cli .Config ) {
60- args := []string {"--systemd-cgroup=true" }
61- opts = append (opts , libcontainerd .WithRuntimeArgs (args ))
62- }
63- if cli .Config .LiveRestoreEnabled {
64- opts = append (opts , libcontainerd .WithLiveRestore (true ))
65- }
66- opts = append (opts , libcontainerd .WithRuntimePath (daemon .DefaultRuntimeBinary ))
67- return opts
69+
70+ return opts , nil
6871}
6972
70- // getLibcontainerdRoot gets the root directory for libcontainerd/containerd to
71- // store their state.
72- func (cli * DaemonCli ) getLibcontainerdRoot () string {
73- return filepath .Join (cli .Config .ExecRoot , "libcontainerd" )
73+ // setupConfigReloadTrap configures the USR2 signal to reload the configuration.
74+ func (cli * DaemonCli ) setupConfigReloadTrap () {
75+ c := make (chan os.Signal , 1 )
76+ signal .Notify (c , unix .SIGHUP )
77+ go func () {
78+ for range c {
79+ cli .reloadConfig ()
80+ }
81+ }()
7482}
7583
7684// getSwarmRunRoot gets the root directory for swarm to store runtime state
0 commit comments