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>
(cherry picked from commit 34eede0296)
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass 2018-09-21 22:58:34 +00:00
parent e69efe2ef5
commit b3bb2aabb8
15 changed files with 52 additions and 42 deletions

View file

@ -3848,10 +3848,10 @@ definitions:
$ref: "#/definitions/Runtime" $ref: "#/definitions/Runtime"
default: default:
runc: runc:
path: "docker-runc" path: "runc"
example: example:
runc: runc:
path: "docker-runc" path: "runc"
runc-master: runc-master:
path: "/go/bin/runc" path: "/go/bin/runc"
custom: custom:

View file

@ -27,7 +27,7 @@ func newExecutor(root, cgroupParent string, net libnetwork.NetworkController) (e
} }
return runcexecutor.New(runcexecutor.Opt{ return runcexecutor.New(runcexecutor.Opt{
Root: filepath.Join(root, "executor"), Root: filepath.Join(root, "executor"),
CommandCandidates: []string{"docker-runc", "runc"}, CommandCandidates: []string{"runc"},
DefaultCgroupParent: cgroupParent, DefaultCgroupParent: cgroupParent,
}, networkProviders) }, networkProviders)
} }

View file

@ -10,6 +10,7 @@ import (
"strings" "strings"
"time" "time"
containerddefaults "github.com/containerd/containerd/defaults"
"github.com/docker/distribution/uuid" "github.com/docker/distribution/uuid"
"github.com/docker/docker/api" "github.com/docker/docker/api"
apiserver "github.com/docker/docker/api/server" apiserver "github.com/docker/docker/api/server"
@ -140,22 +141,25 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
if cli.Config.ContainerdAddr == "" && runtime.GOOS != "windows" { if cli.Config.ContainerdAddr == "" && runtime.GOOS != "windows" {
opts, err := cli.getContainerdDaemonOpts() if !systemContainerdRunning() {
if err != nil { opts, err := cli.getContainerdDaemonOpts()
cancel() if err != nil {
return fmt.Errorf("Failed to generate containerd options: %v", err) cancel()
return fmt.Errorf("Failed to generate containerd options: %v", err)
}
r, err := supervisor.Start(ctx, filepath.Join(cli.Config.Root, "containerd"), filepath.Join(cli.Config.ExecRoot, "containerd"), opts...)
if err != nil {
cancel()
return fmt.Errorf("Failed to start containerd: %v", err)
}
cli.Config.ContainerdAddr = r.Address()
// Try to wait for containerd to shutdown
defer r.WaitTimeout(10 * time.Second)
} else {
cli.Config.ContainerdAddr = containerddefaults.DefaultAddress
} }
r, err := supervisor.Start(ctx, filepath.Join(cli.Config.Root, "containerd"), filepath.Join(cli.Config.ExecRoot, "containerd"), opts...)
if err != nil {
cancel()
return fmt.Errorf("Failed to start containerd: %v", err)
}
cli.Config.ContainerdAddr = r.Address()
// Try to wait for containerd to shutdown
defer r.WaitTimeout(10 * time.Second)
} }
defer cancel() defer cancel()
@ -661,3 +665,8 @@ func validateAuthzPlugins(requestedPlugins []string, pg plugingetter.PluginGette
} }
return nil return nil
} }
func systemContainerdRunning() bool {
_, err := os.Lstat(containerddefaults.DefaultAddress)
return err == nil
}

View file

@ -31,7 +31,7 @@ bundle_files(){
echo $BUNDLE/binary-daemon/$f echo $BUNDLE/binary-daemon/$f
fi fi
done done
for f in docker-containerd docker-containerd-ctr docker-containerd-shim docker-init docker-runc; do for f in containerd ctr containerd-shim docker-init runc; do
echo $BUNDLE/binary-daemon/$f echo $BUNDLE/binary-daemon/$f
done done
if [ -d $BUNDLE/dynbinary-client ]; then if [ -d $BUNDLE/dynbinary-client ]; then

View file

@ -54,11 +54,11 @@ import (
const ( const (
// DefaultShimBinary is the default shim to be used by containerd if none // DefaultShimBinary is the default shim to be used by containerd if none
// is specified // is specified
DefaultShimBinary = "docker-containerd-shim" DefaultShimBinary = "containerd-shim"
// DefaultRuntimeBinary is the default runtime to be used by // DefaultRuntimeBinary is the default runtime to be used by
// containerd if none is specified // containerd if none is specified
DefaultRuntimeBinary = "docker-runc" DefaultRuntimeBinary = "runc"
// See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/tree/kernel/sched/sched.h?id=8cd9234c64c584432f6992fe944ca9e46ca8ea76#n269 // See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/tree/kernel/sched/sched.h?id=8cd9234c64c584432f6992fe944ca9e46ca8ea76#n269
linuxMinCPUShares = 2 linuxMinCPUShares = 2
@ -76,7 +76,7 @@ const (
// DefaultRuntimeName is the default runtime to be used by // DefaultRuntimeName is the default runtime to be used by
// containerd if none is specified // containerd if none is specified
DefaultRuntimeName = "docker-runc" DefaultRuntimeName = "runc"
) )
type containerGetter interface { type containerGetter interface {

View file

@ -30,7 +30,7 @@ install_containerd() {
mkdir -p ${PREFIX} mkdir -p ${PREFIX}
cp bin/containerd ${PREFIX}/docker-containerd cp bin/containerd ${PREFIX}/containerd
cp bin/containerd-shim ${PREFIX}/docker-containerd-shim cp bin/containerd-shim ${PREFIX}/containerd-shim
cp bin/ctr ${PREFIX}/docker-containerd-ctr cp bin/ctr ${PREFIX}/ctr
} }

View file

@ -18,5 +18,5 @@ install_runc() {
fi fi
make BUILDTAGS="$RUNC_BUILDTAGS" "$target" make BUILDTAGS="$RUNC_BUILDTAGS" "$target"
mkdir -p ${PREFIX} mkdir -p ${PREFIX}
cp runc ${PREFIX}/docker-runc cp runc ${PREFIX}/runc
} }

View file

@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
DOCKER_DAEMON_BINARY_NAME='dockerd' DOCKER_DAEMON_BINARY_NAME='dockerd'
DOCKER_RUNC_BINARY_NAME='docker-runc' DOCKER_RUNC_BINARY_NAME='runc'
DOCKER_CONTAINERD_BINARY_NAME='docker-containerd' DOCKER_CONTAINERD_BINARY_NAME='containerd'
DOCKER_CONTAINERD_CTR_BINARY_NAME='docker-containerd-ctr' DOCKER_CONTAINERD_CTR_BINARY_NAME='ctr'
DOCKER_CONTAINERD_SHIM_BINARY_NAME='docker-containerd-shim' DOCKER_CONTAINERD_SHIM_BINARY_NAME='containerd-shim'
DOCKER_PROXY_BINARY_NAME='docker-proxy' DOCKER_PROXY_BINARY_NAME='docker-proxy'
DOCKER_INIT_BINARY_NAME='docker-init' DOCKER_INIT_BINARY_NAME='docker-init'

View file

@ -112,7 +112,7 @@ error_on_leaked_containerd_shims() {
fi fi
leftovers=$(ps -ax -o pid,cmd | leftovers=$(ps -ax -o pid,cmd |
awk '$2 == "docker-containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }') awk '$2 == "containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }')
if [ -n "$leftovers" ]; then if [ -n "$leftovers" ]; then
ps aux ps aux
kill -9 $leftovers 2> /dev/null kill -9 $leftovers 2> /dev/null

View file

@ -32,7 +32,7 @@ const (
privateRegistryURL = registry.DefaultURL privateRegistryURL = registry.DefaultURL
// path to containerd's ctr binary // path to containerd's ctr binary
ctrBinary = "docker-containerd-ctr" ctrBinary = "ctr"
// the docker daemon binary to use // the docker daemon binary to use
dockerdBinary = "dockerd" dockerdBinary = "dockerd"

View file

@ -44,6 +44,8 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
const containerdSocket = "/run/containerd/containerd.sock" // "/var/run/docker/containerd/docker-containerd.sock"
// TestLegacyDaemonCommand test starting docker daemon using "deprecated" docker daemon // TestLegacyDaemonCommand test starting docker daemon using "deprecated" docker daemon
// command. Remove this test when we remove this. // command. Remove this test when we remove this.
func (s *DockerDaemonSuite) TestLegacyDaemonCommand(c *check.C) { func (s *DockerDaemonSuite) TestLegacyDaemonCommand(c *check.C) {
@ -1449,7 +1451,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *chec
c.Assert(d.Kill(), check.IsNil) c.Assert(d.Kill(), check.IsNil)
// kill the container // kill the container
icmd.RunCommand(ctrBinary, "--address", "/var/run/docker/containerd/docker-containerd.sock", icmd.RunCommand(ctrBinary, "--address", containerdSocket,
"--namespace", moby_daemon.ContainersNamespace, "tasks", "kill", id).Assert(c, icmd.Success) "--namespace", moby_daemon.ContainersNamespace, "tasks", "kill", id).Assert(c, icmd.Success)
// restart daemon. // restart daemon.
@ -1971,7 +1973,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check
} }
// kill the container // kill the container
icmd.RunCommand(ctrBinary, "--address", "/var/run/docker/containerd/docker-containerd.sock", icmd.RunCommand(ctrBinary, "--address", containerdSocket,
"--namespace", moby_daemon.ContainersNamespace, "tasks", "kill", cid).Assert(t, icmd.Success) "--namespace", moby_daemon.ContainersNamespace, "tasks", "kill", cid).Assert(t, icmd.Success)
// Give time to containerd to process the command if we don't // Give time to containerd to process the command if we don't
@ -2074,7 +2076,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che
// resume the container // resume the container
result := icmd.RunCommand( result := icmd.RunCommand(
ctrBinary, ctrBinary,
"--address", "/var/run/docker/containerd/docker-containerd.sock", "--address", containerdSocket,
"--namespace", moby_daemon.ContainersNamespace, "--namespace", moby_daemon.ContainersNamespace,
"tasks", "resume", cid) "tasks", "resume", cid)
result.Assert(t, icmd.Success) result.Assert(t, icmd.Success)

View file

@ -224,7 +224,6 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
return errors.Wrapf(err, "[%s] could not find docker binary in $PATH", d.id) return errors.Wrapf(err, "[%s] could not find docker binary in $PATH", d.id)
} }
args := append(d.GlobalFlags, args := append(d.GlobalFlags,
"--containerd", "/var/run/docker/containerd/docker-containerd.sock",
"--data-root", d.Root, "--data-root", d.Root,
"--exec-root", d.execRoot, "--exec-root", d.execRoot,
"--pidfile", fmt.Sprintf("%s/docker.pid", d.Folder), "--pidfile", fmt.Sprintf("%s/docker.pid", d.Folder),

View file

@ -27,8 +27,8 @@ const (
shutdownTimeout = 15 * time.Second shutdownTimeout = 15 * time.Second
startupTimeout = 15 * time.Second startupTimeout = 15 * time.Second
configFile = "containerd.toml" configFile = "containerd.toml"
binaryName = "docker-containerd" binaryName = "containerd"
pidFile = "docker-containerd.pid" pidFile = "containerd.pid"
) )
type pluginConfigs struct { type pluginConfigs struct {

View file

@ -11,8 +11,8 @@ import (
) )
const ( const (
sockFile = "docker-containerd.sock" sockFile = "containerd.sock"
debugSockFile = "docker-containerd-debug.sock" debugSockFile = "containerd-debug.sock"
) )
func (r *remote) setDefaults() { func (r *remote) setDefaults() {

View file

@ -7,8 +7,8 @@ import (
) )
const ( const (
grpcPipeName = `\\.\pipe\docker-containerd-containerd` grpcPipeName = `\\.\pipe\containerd-containerd`
debugPipeName = `\\.\pipe\docker-containerd-debug` debugPipeName = `\\.\pipe\containerd-debug`
) )
func (r *remote) setDefaults() { func (r *remote) setDefaults() {