@@ -10,9 +10,11 @@ import (
10
10
"path/filepath"
11
11
"strconv"
12
12
13
+ "github.com/containerd/containerd/linux"
13
14
"github.com/docker/docker/cmd/dockerd/hack"
14
15
"github.com/docker/docker/daemon"
15
16
"github.com/docker/docker/libcontainerd"
17
+ "github.com/docker/docker/pkg/parsers/kernel"
16
18
"github.com/docker/libnetwork/portallocator"
17
19
"golang.org/x/sys/unix"
18
20
)
@@ -35,42 +37,48 @@ func getDaemonConfDir(_ string) string {
35
37
return "/etc/docker"
36
38
}
37
39
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
+ }
48
50
49
- func (cli * DaemonCli ) getPlatformRemoteOptions () []libcontainerd.RemoteOption {
50
51
opts := []libcontainerd.RemoteOption {
51
- libcontainerd .WithDebugLog (cli .Config .Debug ),
52
52
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" ))
53
63
}
54
64
if cli .Config .ContainerdAddr != "" {
55
65
opts = append (opts , libcontainerd .WithRemoteAddr (cli .Config .ContainerdAddr ))
56
66
} else {
57
67
opts = append (opts , libcontainerd .WithStartDaemon (true ))
58
68
}
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
68
71
}
69
72
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
+ }()
74
82
}
75
83
76
84
// getSwarmRunRoot gets the root directory for swarm to store runtime state
0 commit comments