Browse code

Remove 'docker-' prefix for containerd and runc binaries

This allows to run the daemon in environments that have upstream containerd installed.

Signed-off-by: Tibor Vass <tibor@docker.com>

Tibor Vass authored on 2018/09/22 07:58:34
Showing 15 changed files
... ...
@@ -3848,10 +3848,10 @@ definitions:
3848 3848
           $ref: "#/definitions/Runtime"
3849 3849
         default:
3850 3850
           runc:
3851
-            path: "docker-runc"
3851
+            path: "runc"
3852 3852
         example:
3853 3853
           runc:
3854
-            path: "docker-runc"
3854
+            path: "runc"
3855 3855
           runc-master:
3856 3856
             path: "/go/bin/runc"
3857 3857
           custom:
... ...
@@ -27,7 +27,7 @@ func newExecutor(root, cgroupParent string, net libnetwork.NetworkController) (e
27 27
 	}
28 28
 	return runcexecutor.New(runcexecutor.Opt{
29 29
 		Root:                filepath.Join(root, "executor"),
30
-		CommandCandidates:   []string{"docker-runc", "runc"},
30
+		CommandCandidates:   []string{"runc"},
31 31
 		DefaultCgroupParent: cgroupParent,
32 32
 	}, networkProviders)
33 33
 }
... ...
@@ -10,6 +10,7 @@ import (
10 10
 	"strings"
11 11
 	"time"
12 12
 
13
+	containerddefaults "github.com/containerd/containerd/defaults"
13 14
 	"github.com/docker/distribution/uuid"
14 15
 	"github.com/docker/docker/api"
15 16
 	apiserver "github.com/docker/docker/api/server"
... ...
@@ -140,22 +141,25 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
140 140
 
141 141
 	ctx, cancel := context.WithCancel(context.Background())
142 142
 	if cli.Config.ContainerdAddr == "" && runtime.GOOS != "windows" {
143
-		opts, err := cli.getContainerdDaemonOpts()
144
-		if err != nil {
145
-			cancel()
146
-			return errors.Wrap(err, "failed to generate containerd options")
147
-		}
148
-
149
-		r, err := supervisor.Start(ctx, filepath.Join(cli.Config.Root, "containerd"), filepath.Join(cli.Config.ExecRoot, "containerd"), opts...)
150
-		if err != nil {
151
-			cancel()
152
-			return errors.Wrap(err, "failed to start containerd")
153
-		}
143
+		if !systemContainerdRunning() {
144
+			opts, err := cli.getContainerdDaemonOpts()
145
+			if err != nil {
146
+				cancel()
147
+				return errors.Wrap(err, "failed to generate containerd options")
148
+			}
154 149
 
155
-		cli.Config.ContainerdAddr = r.Address()
150
+			r, err := supervisor.Start(ctx, filepath.Join(cli.Config.Root, "containerd"), filepath.Join(cli.Config.ExecRoot, "containerd"), opts...)
151
+			if err != nil {
152
+				cancel()
153
+				return errors.Wrap(err, "failed to start containerd")
154
+			}
155
+			cli.Config.ContainerdAddr = r.Address()
156 156
 
157
-		// Try to wait for containerd to shutdown
158
-		defer r.WaitTimeout(10 * time.Second)
157
+			// Try to wait for containerd to shutdown
158
+			defer r.WaitTimeout(10 * time.Second)
159
+		} else {
160
+			cli.Config.ContainerdAddr = containerddefaults.DefaultAddress
161
+		}
159 162
 	}
160 163
 	defer cancel()
161 164
 
... ...
@@ -661,3 +665,8 @@ func validateAuthzPlugins(requestedPlugins []string, pg plugingetter.PluginGette
661 661
 	}
662 662
 	return nil
663 663
 }
664
+
665
+func systemContainerdRunning() bool {
666
+	_, err := os.Lstat(containerddefaults.DefaultAddress)
667
+	return err == nil
668
+}
... ...
@@ -31,7 +31,7 @@ bundle_files(){
31 31
 	    echo $BUNDLE/binary-daemon/$f
32 32
 	fi
33 33
     done
34
-    for f in docker-containerd docker-containerd-ctr docker-containerd-shim docker-init docker-runc; do
34
+    for f in containerd ctr containerd-shim docker-init runc; do
35 35
 	echo $BUNDLE/binary-daemon/$f
36 36
     done
37 37
     if [ -d $BUNDLE/dynbinary-client ]; then
... ...
@@ -54,11 +54,11 @@ import (
54 54
 const (
55 55
 	// DefaultShimBinary is the default shim to be used by containerd if none
56 56
 	// is specified
57
-	DefaultShimBinary = "docker-containerd-shim"
57
+	DefaultShimBinary = "containerd-shim"
58 58
 
59 59
 	// DefaultRuntimeBinary is the default runtime to be used by
60 60
 	// containerd if none is specified
61
-	DefaultRuntimeBinary = "docker-runc"
61
+	DefaultRuntimeBinary = "runc"
62 62
 
63 63
 	// See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/tree/kernel/sched/sched.h?id=8cd9234c64c584432f6992fe944ca9e46ca8ea76#n269
64 64
 	linuxMinCPUShares = 2
... ...
@@ -76,7 +76,7 @@ const (
76 76
 
77 77
 	// DefaultRuntimeName is the default runtime to be used by
78 78
 	// containerd if none is specified
79
-	DefaultRuntimeName = "docker-runc"
79
+	DefaultRuntimeName = "runc"
80 80
 )
81 81
 
82 82
 type containerGetter interface {
... ...
@@ -30,7 +30,7 @@ install_containerd() {
30 30
 
31 31
 	mkdir -p ${PREFIX}
32 32
 
33
-	cp bin/containerd ${PREFIX}/docker-containerd
34
-	cp bin/containerd-shim ${PREFIX}/docker-containerd-shim
35
-	cp bin/ctr ${PREFIX}/docker-containerd-ctr
33
+	cp bin/containerd ${PREFIX}/containerd
34
+	cp bin/containerd-shim ${PREFIX}/containerd-shim
35
+	cp bin/ctr ${PREFIX}/ctr
36 36
 }
... ...
@@ -18,5 +18,5 @@ install_runc() {
18 18
 	fi
19 19
 	make BUILDTAGS="$RUNC_BUILDTAGS" "$target"
20 20
 	mkdir -p ${PREFIX}
21
-	cp runc ${PREFIX}/docker-runc
21
+	cp runc ${PREFIX}/runc
22 22
 }
... ...
@@ -1,9 +1,9 @@
1 1
 #!/usr/bin/env bash
2 2
 
3 3
 DOCKER_DAEMON_BINARY_NAME='dockerd'
4
-DOCKER_RUNC_BINARY_NAME='docker-runc'
5
-DOCKER_CONTAINERD_BINARY_NAME='docker-containerd'
6
-DOCKER_CONTAINERD_CTR_BINARY_NAME='docker-containerd-ctr'
7
-DOCKER_CONTAINERD_SHIM_BINARY_NAME='docker-containerd-shim'
4
+DOCKER_RUNC_BINARY_NAME='runc'
5
+DOCKER_CONTAINERD_BINARY_NAME='containerd'
6
+DOCKER_CONTAINERD_CTR_BINARY_NAME='ctr'
7
+DOCKER_CONTAINERD_SHIM_BINARY_NAME='containerd-shim'
8 8
 DOCKER_PROXY_BINARY_NAME='docker-proxy'
9 9
 DOCKER_INIT_BINARY_NAME='docker-init'
... ...
@@ -112,7 +112,7 @@ error_on_leaked_containerd_shims() {
112 112
 	fi
113 113
 
114 114
 	leftovers=$(ps -ax -o pid,cmd |
115
-	            awk '$2 == "docker-containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }')
115
+	            awk '$2 == "containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }')
116 116
 	if [ -n "$leftovers" ]; then
117 117
 		ps aux
118 118
 		kill -9 $leftovers 2> /dev/null
... ...
@@ -32,7 +32,7 @@ const (
32 32
 	privateRegistryURL = registry.DefaultURL
33 33
 
34 34
 	// path to containerd's ctr binary
35
-	ctrBinary = "docker-containerd-ctr"
35
+	ctrBinary = "ctr"
36 36
 
37 37
 	// the docker daemon binary to use
38 38
 	dockerdBinary = "dockerd"
... ...
@@ -44,6 +44,8 @@ import (
44 44
 	"gotest.tools/icmd"
45 45
 )
46 46
 
47
+const containerdSocket = "/run/containerd/containerd.sock" // "/var/run/docker/containerd/docker-containerd.sock"
48
+
47 49
 // TestLegacyDaemonCommand test starting docker daemon using "deprecated" docker daemon
48 50
 // command. Remove this test when we remove this.
49 51
 func (s *DockerDaemonSuite) TestLegacyDaemonCommand(c *check.C) {
... ...
@@ -1449,7 +1451,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *chec
1449 1449
 	c.Assert(d.Kill(), check.IsNil)
1450 1450
 
1451 1451
 	// kill the container
1452
-	icmd.RunCommand(ctrBinary, "--address", "/var/run/docker/containerd/docker-containerd.sock",
1452
+	icmd.RunCommand(ctrBinary, "--address", containerdSocket,
1453 1453
 		"--namespace", moby_daemon.ContainersNamespace, "tasks", "kill", id).Assert(c, icmd.Success)
1454 1454
 
1455 1455
 	// restart daemon.
... ...
@@ -1971,7 +1973,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check
1971 1971
 	}
1972 1972
 
1973 1973
 	// kill the container
1974
-	icmd.RunCommand(ctrBinary, "--address", "/var/run/docker/containerd/docker-containerd.sock",
1974
+	icmd.RunCommand(ctrBinary, "--address", containerdSocket,
1975 1975
 		"--namespace", moby_daemon.ContainersNamespace, "tasks", "kill", cid).Assert(t, icmd.Success)
1976 1976
 
1977 1977
 	// Give time to containerd to process the command if we don't
... ...
@@ -2074,7 +2076,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che
2074 2074
 	// resume the container
2075 2075
 	result := icmd.RunCommand(
2076 2076
 		ctrBinary,
2077
-		"--address", "/var/run/docker/containerd/docker-containerd.sock",
2077
+		"--address", containerdSocket,
2078 2078
 		"--namespace", moby_daemon.ContainersNamespace,
2079 2079
 		"tasks", "resume", cid)
2080 2080
 	result.Assert(t, icmd.Success)
... ...
@@ -224,7 +224,6 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
224 224
 		return errors.Wrapf(err, "[%s] could not find docker binary in $PATH", d.id)
225 225
 	}
226 226
 	args := append(d.GlobalFlags,
227
-		"--containerd", "/var/run/docker/containerd/docker-containerd.sock",
228 227
 		"--data-root", d.Root,
229 228
 		"--exec-root", d.execRoot,
230 229
 		"--pidfile", fmt.Sprintf("%s/docker.pid", d.Folder),
... ...
@@ -27,8 +27,8 @@ const (
27 27
 	shutdownTimeout         = 15 * time.Second
28 28
 	startupTimeout          = 15 * time.Second
29 29
 	configFile              = "containerd.toml"
30
-	binaryName              = "docker-containerd"
31
-	pidFile                 = "docker-containerd.pid"
30
+	binaryName              = "containerd"
31
+	pidFile                 = "containerd.pid"
32 32
 )
33 33
 
34 34
 type pluginConfigs struct {
... ...
@@ -11,8 +11,8 @@ import (
11 11
 )
12 12
 
13 13
 const (
14
-	sockFile      = "docker-containerd.sock"
15
-	debugSockFile = "docker-containerd-debug.sock"
14
+	sockFile      = "containerd.sock"
15
+	debugSockFile = "containerd-debug.sock"
16 16
 )
17 17
 
18 18
 func (r *remote) setDefaults() {
... ...
@@ -7,8 +7,8 @@ import (
7 7
 )
8 8
 
9 9
 const (
10
-	grpcPipeName  = `\\.\pipe\docker-containerd-containerd`
11
-	debugPipeName = `\\.\pipe\docker-containerd-debug`
10
+	grpcPipeName  = `\\.\pipe\containerd-containerd`
11
+	debugPipeName = `\\.\pipe\containerd-debug`
12 12
 )
13 13
 
14 14
 func (r *remote) setDefaults() {