Skip to content

Commit

Permalink
Merge pull request moby#22983 from mlaventure/multiple-runtimes
Browse files Browse the repository at this point in the history
Add support for multiple runtimes
  • Loading branch information
crosbymichael committed Jun 14, 2016
2 parents 87f31e3 + 77efe6d commit 6381ed1
Show file tree
Hide file tree
Showing 45 changed files with 882 additions and 242 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,18 @@ RUN set -x \
&& rm -rf "$GOPATH"

# Install runc
ENV RUNC_COMMIT d49ece5a83da3dcb820121d6850e2b61bd0a5fbe
ENV RUNC_COMMIT 5ce88a95f6cf218ba7f3309562f95464a968e890
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& git clone https://github.com/crosbymichael/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
&& git checkout -q "$RUNC_COMMIT" \
&& make static BUILDTAGS="seccomp apparmor selinux" \
&& cp runc /usr/local/bin/docker-runc \
&& rm -rf "$GOPATH"

# Install containerd
ENV CONTAINERD_COMMIT cf554d59dd96e459544748290eb9167f4bcde509
ENV CONTAINERD_COMMIT 860f3a94940894ac0a106eff4bd1616a67407ee2
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,18 @@ RUN set -x \
&& rm -rf "$GOPATH"

# Install runc
ENV RUNC_COMMIT d49ece5a83da3dcb820121d6850e2b61bd0a5fbe
ENV RUNC_COMMIT 5ce88a95f6cf218ba7f3309562f95464a968e890
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& git clone https://github.com/crosbymichael/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
&& git checkout -q "$RUNC_COMMIT" \
&& make static BUILDTAGS="seccomp apparmor selinux" \
&& cp runc /usr/local/bin/docker-runc \
&& rm -rf "$GOPATH"

# Install containerd
ENV CONTAINERD_COMMIT cf554d59dd96e459544748290eb9167f4bcde509
ENV CONTAINERD_COMMIT 860f3a94940894ac0a106eff4bd1616a67407ee2
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,18 @@ RUN set -x \
&& rm -rf "$GOPATH"

# Install runc
ENV RUNC_COMMIT d49ece5a83da3dcb820121d6850e2b61bd0a5fbe
ENV RUNC_COMMIT 5ce88a95f6cf218ba7f3309562f95464a968e890
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& git clone https://github.com/crosbymichael/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
&& git checkout -q "$RUNC_COMMIT" \
&& make static BUILDTAGS="seccomp apparmor selinux" \
&& cp runc /usr/local/bin/docker-runc \
&& rm -rf "$GOPATH"

# Install containerd
ENV CONTAINERD_COMMIT cf554d59dd96e459544748290eb9167f4bcde509
ENV CONTAINERD_COMMIT 860f3a94940894ac0a106eff4bd1616a67407ee2
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.gccgo
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@ WORKDIR /go/src/github.com/docker/docker
ENV DOCKER_BUILDTAGS apparmor seccomp selinux

# Install runc
ENV RUNC_COMMIT d49ece5a83da3dcb820121d6850e2b61bd0a5fbe
ENV RUNC_COMMIT 5ce88a95f6cf218ba7f3309562f95464a968e890
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& git clone https://github.com/crosbymichael/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
&& git checkout -q "$RUNC_COMMIT" \
&& make static BUILDTAGS="seccomp apparmor selinux" \
&& cp runc /usr/local/bin/docker-runc \
&& rm -rf "$GOPATH"

# Install containerd
ENV CONTAINERD_COMMIT cf554d59dd96e459544748290eb9167f4bcde509
ENV CONTAINERD_COMMIT 860f3a94940894ac0a106eff4bd1616a67407ee2
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,18 @@ RUN set -x \
&& rm -rf "$GOPATH"

# Install runc
ENV RUNC_COMMIT d49ece5a83da3dcb820121d6850e2b61bd0a5fbe
ENV RUNC_COMMIT 5ce88a95f6cf218ba7f3309562f95464a968e890
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& git clone https://github.com/crosbymichael/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
&& git checkout -q "$RUNC_COMMIT" \
&& make static BUILDTAGS="apparmor seccomp selinux" \
&& cp runc /usr/local/bin/docker-runc \
&& rm -rf "$GOPATH"

# Install containerd
ENV CONTAINERD_COMMIT cf554d59dd96e459544748290eb9167f4bcde509
ENV CONTAINERD_COMMIT 860f3a94940894ac0a106eff4bd1616a67407ee2
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.s390x
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,18 @@ RUN set -x \
&& rm -rf "$GOPATH"

# Install runc
ENV RUNC_COMMIT d49ece5a83da3dcb820121d6850e2b61bd0a5fbe
ENV RUNC_COMMIT 5ce88a95f6cf218ba7f3309562f95464a968e890
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& git clone https://github.com/crosbymichael/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
&& git checkout -q "$RUNC_COMMIT" \
&& make static BUILDTAGS="seccomp apparmor selinux" \
&& cp runc /usr/local/bin/docker-runc \
&& rm -rf "$GOPATH"

# Install containerd
ENV CONTAINERD_COMMIT cf554d59dd96e459544748290eb9167f4bcde509
ENV CONTAINERD_COMMIT 860f3a94940894ac0a106eff4bd1616a67407ee2
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.simple
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ ENV GOPATH /go:/go/src/github.com/docker/docker/vendor
ENV CGO_LDFLAGS -L/lib

# Install runc
ENV RUNC_COMMIT d49ece5a83da3dcb820121d6850e2b61bd0a5fbe
ENV RUNC_COMMIT 5ce88a95f6cf218ba7f3309562f95464a968e890
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& git clone https://github.com/crosbymichael/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
&& git checkout -q "$RUNC_COMMIT" \
&& make static BUILDTAGS="seccomp apparmor selinux" \
&& cp runc /usr/local/bin/docker-runc \
&& rm -rf "$GOPATH"

# Install containerd
ENV CONTAINERD_COMMIT cf554d59dd96e459544748290eb9167f4bcde509
ENV CONTAINERD_COMMIT 860f3a94940894ac0a106eff4bd1616a67407ee2
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
Expand Down
12 changes: 11 additions & 1 deletion api/client/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
ioutils.FprintfIfNotEmpty(cli.out, "Logging Driver: %s\n", info.LoggingDriver)
ioutils.FprintfIfNotEmpty(cli.out, "Cgroup Driver: %s\n", info.CgroupDriver)

fmt.Fprintf(cli.out, "Plugins: \n")
fmt.Fprintf(cli.out, "Plugins:\n")
fmt.Fprintf(cli.out, " Volume:")
fmt.Fprintf(cli.out, " %s", strings.Join(info.Plugins.Volume, " "))
fmt.Fprintf(cli.out, "\n")
Expand Down Expand Up @@ -84,6 +84,16 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
fmt.Fprintf(cli.out, " IsManager: No\n")
}
}

if len(info.Runtimes) > 0 {
fmt.Fprintf(cli.out, "Runtimes:")
for name := range info.Runtimes {
fmt.Fprintf(cli.out, " %s", name)
}
fmt.Fprint(cli.out, "\n")
fmt.Fprintf(cli.out, "Default Runtime: %s\n", info.DefaultRuntime)
}

ioutils.FprintfIfNotEmpty(cli.out, "Kernel Version: %s\n", info.KernelVersion)
ioutils.FprintfIfNotEmpty(cli.out, "Operating System: %s\n", info.OperatingSystem)
ioutils.FprintfIfNotEmpty(cli.out, "OSType: %s\n", info.OSType)
Expand Down
4 changes: 4 additions & 0 deletions cmd/dockerd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ func loadDaemonCliConfig(config *daemon.Config, flags *flag.FlagSet, commonConfi
}
}

if err := daemon.ValidateConfiguration(config); err != nil {
return nil, err
}

// Regardless of whether the user sets it to true or false, if they
// specify TLSVerify at all then we need to turn on TLS
if config.IsValueSet(cliflags.TLSVerifyKey) {
Expand Down
1 change: 1 addition & 0 deletions cmd/dockerd/daemon_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (cli *DaemonCli) getPlatformRemoteOptions() []libcontainerd.RemoteOption {
if cli.Config.LiveRestore {
opts = append(opts, libcontainerd.WithLiveRestore(true))
}
opts = append(opts, libcontainerd.WithRuntimePath(daemon.DefaultRuntimeBinary))
return opts
}

Expand Down
17 changes: 16 additions & 1 deletion contrib/completion/bash/docker
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ __docker_complete_plugins() {
COMPREPLY=( $(compgen -W "$(__docker_plugins $1)" -- "$cur") )
}

__docker_runtimes() {
__docker_q info | sed -n 's/^Runtimes: \(.*\)/\1/p'
}

__docker_complete_runtimes() {
COMPREPLY=( $(compgen -W "$(__docker_runtimes)" -- "$cur") )
}

# Finds the position of the first word that is neither option nor an option's argument.
# If there are options that require arguments, you should pass a glob describing those
# options, e.g. "--option1|-o|--option2"
Expand Down Expand Up @@ -791,6 +799,7 @@ _docker_daemon() {
"
local options_with_args="
$global_options_with_args
--add-runtime
--api-cors-header
--authorization-plugin
--bip
Expand All @@ -799,6 +808,7 @@ _docker_daemon() {
--cluster-advertise
--cluster-store
--cluster-store-opt
--config-file
--containerd
--default-gateway
--default-gateway-v6
Expand Down Expand Up @@ -878,7 +888,7 @@ _docker_daemon() {
__docker_complete_log_drivers
return
;;
--containerd|--pidfile|-p|--tlscacert|--tlscert|--tlskey)
--config-file|--containerd|--pidfile|-p|--tlscacert|--tlscert|--tlskey)
_filedir
return
;;
Expand Down Expand Up @@ -1705,6 +1715,7 @@ _docker_run() {
--pids-limit
--publish -p
--restart
--runtime
--security-opt
--shm-size
--stop-signal
Expand Down Expand Up @@ -1883,6 +1894,10 @@ _docker_run() {
esac
return
;;
--runtime)
__docker_complete_runtimes
return
;;
--security-opt)
COMPREPLY=( $( compgen -W "apparmor= label= no-new-privileges seccomp=" -- "$cur") )
if [ "${COMPREPLY[*]}" != "no-new-privileges" ] ; then
Expand Down
1 change: 1 addition & 0 deletions contrib/completion/zsh/_docker
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ __docker_subcommand() {
"($help -b --bridge)"{-b=,--bridge=}"[Attach containers to a network bridge]:bridge:_net_interfaces" \
"($help)--bip=[Network bridge IP]:IP address: " \
"($help)--cgroup-parent=[Parent cgroup for all containers]:cgroup: " \
"($help)--config-file=[Path to daemon configuration file]:Config File:_files" \
"($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \
"($help -D --debug)"{-D,--debug}"[Enable debug mode]" \
"($help)--default-gateway[Container default gateway IPv4 address]:IPv4 address: " \
Expand Down
31 changes: 27 additions & 4 deletions daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/docker/docker/pkg/discovery"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/registry"
"github.com/docker/engine-api/types"
"github.com/imdario/mergo"
)

Expand All @@ -40,6 +41,7 @@ const (
var flatOptions = map[string]bool{
"cluster-store-opts": true,
"log-opts": true,
"runtimes": true,
}

// LogConfig represents the default log configuration.
Expand Down Expand Up @@ -200,7 +202,7 @@ func ReloadConfiguration(configFile string, flags *flag.FlagSet, reload func(*Co
return err
}

if err := validateConfiguration(newConfig); err != nil {
if err := ValidateConfiguration(newConfig); err != nil {
return fmt.Errorf("file configuration validation failed (%v)", err)
}

Expand All @@ -224,7 +226,7 @@ func MergeDaemonConfigurations(flagsConfig *Config, flags *flag.FlagSet, configF
return nil, err
}

if err := validateConfiguration(fileConfig); err != nil {
if err := ValidateConfiguration(fileConfig); err != nil {
return nil, fmt.Errorf("file configuration validation failed (%v)", err)
}

Expand All @@ -233,6 +235,12 @@ func MergeDaemonConfigurations(flagsConfig *Config, flags *flag.FlagSet, configF
return nil, err
}

// We need to validate again once both fileConfig and flagsConfig
// have been merged
if err := ValidateConfiguration(fileConfig); err != nil {
return nil, fmt.Errorf("file configuration validation failed (%v)", err)
}

return fileConfig, nil
}

Expand Down Expand Up @@ -381,10 +389,10 @@ func findConfigurationConflicts(config map[string]interface{}, flags *flag.FlagS
return nil
}

// validateConfiguration validates some specific configs.
// ValidateConfiguration validates some specific configs.
// such as config.DNS, config.Labels, config.DNSSearch,
// as well as config.MaxConcurrentDownloads, config.MaxConcurrentUploads.
func validateConfiguration(config *Config) error {
func ValidateConfiguration(config *Config) error {
// validate DNS
for _, dns := range config.DNS {
if _, err := opts.ValidateIPAddress(dns); err != nil {
Expand Down Expand Up @@ -415,5 +423,20 @@ func validateConfiguration(config *Config) error {
if config.IsValueSet("max-concurrent-uploads") && config.MaxConcurrentUploads != nil && *config.MaxConcurrentUploads < 0 {
return fmt.Errorf("invalid max concurrent uploads: %d", *config.MaxConcurrentUploads)
}

// validate that "default" runtime is not reset
if runtimes := config.GetAllRuntimes(); len(runtimes) > 0 {
if _, ok := runtimes[types.DefaultRuntimeName]; ok {
return fmt.Errorf("runtime name '%s' is reserved", types.DefaultRuntimeName)
}
}

if defaultRuntime := config.GetDefaultRuntimeName(); defaultRuntime != "" && defaultRuntime != types.DefaultRuntimeName {
runtimes := config.GetAllRuntimes()
if _, ok := runtimes[defaultRuntime]; !ok {
return fmt.Errorf("specified default runtime '%s' does not exist", defaultRuntime)
}
}

return nil
}

0 comments on commit 6381ed1

Please sign in to comment.