Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
| ... | ... |
@@ -236,6 +236,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ |
| 236 | 236 |
|
| 237 | 237 |
# Install tomlv, vndr, runc, containerd, tini, docker-proxy |
| 238 | 238 |
# Please edit hack/dockerfile/install-binaries.sh to update them. |
| 239 |
+COPY hack/dockerfile/binaries-commits /tmp/binaries-commits |
|
| 239 | 240 |
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh |
| 240 | 241 |
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy |
| 241 | 242 |
|
| ... | ... |
@@ -164,6 +164,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ |
| 164 | 164 |
|
| 165 | 165 |
# Install tomlv, vndr, runc, containerd, tini, docker-proxy |
| 166 | 166 |
# Please edit hack/dockerfile/install-binaries.sh to update them. |
| 167 |
+COPY hack/dockerfile/binaries-commits /tmp/binaries-commits |
|
| 167 | 168 |
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh |
| 168 | 169 |
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy |
| 169 | 170 |
|
| ... | ... |
@@ -168,6 +168,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ |
| 168 | 168 |
|
| 169 | 169 |
# Install tomlv, vndr, runc, containerd, tini, docker-proxy |
| 170 | 170 |
# Please edit hack/dockerfile/install-binaries.sh to update them. |
| 171 |
+COPY hack/dockerfile/binaries-commits /tmp/binaries-commits |
|
| 171 | 172 |
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh |
| 172 | 173 |
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy |
| 173 | 174 |
|
| ... | ... |
@@ -187,6 +187,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ |
| 187 | 187 |
|
| 188 | 188 |
# Install tomlv, vndr, runc, containerd, tini, docker-proxy |
| 189 | 189 |
# Please edit hack/dockerfile/install-binaries.sh to update them. |
| 190 |
+COPY hack/dockerfile/binaries-commits /tmp/binaries-commits |
|
| 190 | 191 |
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh |
| 191 | 192 |
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy |
| 192 | 193 |
|
| ... | ... |
@@ -179,6 +179,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ |
| 179 | 179 |
|
| 180 | 180 |
# Install tomlv, vndr, runc, containerd, tini, docker-proxy |
| 181 | 181 |
# Please edit hack/dockerfile/install-binaries.sh to update them. |
| 182 |
+COPY hack/dockerfile/binaries-commits /tmp/binaries-commits |
|
| 182 | 183 |
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh |
| 183 | 184 |
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy |
| 184 | 185 |
|
| ... | ... |
@@ -60,6 +60,7 @@ ENV CGO_LDFLAGS -L/lib |
| 60 | 60 |
|
| 61 | 61 |
# Install runc, containerd, tini and docker-proxy |
| 62 | 62 |
# Please edit hack/dockerfile/install-binaries.sh to update them. |
| 63 |
+COPY hack/dockerfile/binaries-commits /tmp/binaries-commits |
|
| 63 | 64 |
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh |
| 64 | 65 |
RUN /tmp/install-binaries.sh runc containerd tini proxy |
| 65 | 66 |
|
| ... | ... |
@@ -150,6 +150,13 @@ type Version struct {
|
| 150 | 150 |
BuildTime string `json:",omitempty"` |
| 151 | 151 |
} |
| 152 | 152 |
|
| 153 |
+// Commit records a external tool actual commit id version along the |
|
| 154 |
+// one expect by dockerd as set at build time |
|
| 155 |
+type Commit struct {
|
|
| 156 |
+ ID string |
|
| 157 |
+ Expected string |
|
| 158 |
+} |
|
| 159 |
+ |
|
| 153 | 160 |
// InfoBase contains the base response of Remote API: |
| 154 | 161 |
// GET "/info" |
| 155 | 162 |
type InfoBase struct {
|
| ... | ... |
@@ -207,6 +214,10 @@ type InfoBase struct {
|
| 207 | 207 |
// running containers are detected |
| 208 | 208 |
LiveRestoreEnabled bool |
| 209 | 209 |
Isolation container.Isolation |
| 210 |
+ InitBinary string |
|
| 211 |
+ ContainerdCommit Commit |
|
| 212 |
+ RuncCommit Commit |
|
| 213 |
+ InitCommit Commit |
|
| 210 | 214 |
} |
| 211 | 215 |
|
| 212 | 216 |
// SecurityOpt holds key/value pair about a security option |
| ... | ... |
@@ -143,6 +143,22 @@ func prettyPrintInfo(dockerCli *command.DockerCli, info types.Info) error {
|
| 143 | 143 |
} |
| 144 | 144 |
|
| 145 | 145 |
if info.OSType == "linux" {
|
| 146 |
+ fmt.Fprintf(dockerCli.Out(), "Init Binary: %v\n", info.InitBinary) |
|
| 147 |
+ |
|
| 148 |
+ for _, ci := range []struct {
|
|
| 149 |
+ Name string |
|
| 150 |
+ Commit types.Commit |
|
| 151 |
+ }{
|
|
| 152 |
+ {"containerd", info.ContainerdCommit},
|
|
| 153 |
+ {"runc", info.RuncCommit},
|
|
| 154 |
+ {"init", info.InitCommit},
|
|
| 155 |
+ } {
|
|
| 156 |
+ fmt.Fprintf(dockerCli.Out(), "%s version: %s", ci.Name, ci.Commit.ID) |
|
| 157 |
+ if ci.Commit.ID != ci.Commit.Expected {
|
|
| 158 |
+ fmt.Fprintf(dockerCli.Out(), " (expected: %s)", ci.Commit.Expected) |
|
| 159 |
+ } |
|
| 160 |
+ fmt.Fprintf(dockerCli.Out(), "\n") |
|
| 161 |
+ } |
|
| 146 | 162 |
if len(info.SecurityOptions) != 0 {
|
| 147 | 163 |
fmt.Fprintf(dockerCli.Out(), "Security Options:\n") |
| 148 | 164 |
for _, o := range info.SecurityOptions {
|
| ... | ... |
@@ -78,3 +78,13 @@ func (config *Config) GetAllRuntimes() map[string]types.Runtime {
|
| 78 | 78 |
func (config *Config) GetExecRoot() string {
|
| 79 | 79 |
return config.ExecRoot |
| 80 | 80 |
} |
| 81 |
+ |
|
| 82 |
+// GetInitPath returns the configure docker-init path |
|
| 83 |
+func (config *Config) GetInitPath() string {
|
|
| 84 |
+ config.reloadLock.Lock() |
|
| 85 |
+ defer config.reloadLock.Unlock() |
|
| 86 |
+ if config.InitPath != "" {
|
|
| 87 |
+ return config.InitPath |
|
| 88 |
+ } |
|
| 89 |
+ return DefaultInitBinary |
|
| 90 |
+} |
| ... | ... |
@@ -46,6 +46,11 @@ func (config *Config) GetRuntime(name string) *types.Runtime {
|
| 46 | 46 |
return nil |
| 47 | 47 |
} |
| 48 | 48 |
|
| 49 |
+// GetInitPath returns the configure docker-init path |
|
| 50 |
+func (config *Config) GetInitPath() string {
|
|
| 51 |
+ return "" |
|
| 52 |
+} |
|
| 53 |
+ |
|
| 49 | 54 |
// GetDefaultRuntimeName returns the current default runtime |
| 50 | 55 |
func (config *Config) GetDefaultRuntimeName() string {
|
| 51 | 56 |
return stockRuntimeName |
| ... | ... |
@@ -66,6 +66,9 @@ var ( |
| 66 | 66 |
// containerd if none is specified |
| 67 | 67 |
DefaultRuntimeBinary = "docker-runc" |
| 68 | 68 |
|
| 69 |
+ // DefaultInitBinary is the name of the default init binary |
|
| 70 |
+ DefaultInitBinary = "docker-init" |
|
| 71 |
+ |
|
| 69 | 72 |
errSystemNotSupported = fmt.Errorf("The Docker daemon is not supported on this platform.")
|
| 70 | 73 |
) |
| 71 | 74 |
|
| ... | ... |
@@ -1,8 +1,11 @@ |
| 1 | 1 |
package daemon |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "context" |
|
| 4 | 5 |
"os" |
| 6 |
+ "os/exec" |
|
| 5 | 7 |
"runtime" |
| 8 |
+ "strings" |
|
| 6 | 9 |
"sync/atomic" |
| 7 | 10 |
"time" |
| 8 | 11 |
|
| ... | ... |
@@ -147,6 +150,47 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
|
| 147 | 147 |
v.CPUSet = sysInfo.Cpuset |
| 148 | 148 |
v.Runtimes = daemon.configStore.GetAllRuntimes() |
| 149 | 149 |
v.DefaultRuntime = daemon.configStore.GetDefaultRuntimeName() |
| 150 |
+ v.InitBinary = daemon.configStore.GetInitPath() |
|
| 151 |
+ |
|
| 152 |
+ v.ContainerdCommit.Expected = dockerversion.ContainerdCommitID |
|
| 153 |
+ if sv, err := daemon.containerd.GetServerVersion(context.Background()); err == nil {
|
|
| 154 |
+ v.ContainerdCommit.ID = sv.Revision |
|
| 155 |
+ } else {
|
|
| 156 |
+ logrus.Warnf("failed to retrieve containerd version: %v", err)
|
|
| 157 |
+ v.ContainerdCommit.ID = "N/A" |
|
| 158 |
+ } |
|
| 159 |
+ |
|
| 160 |
+ v.RuncCommit.Expected = dockerversion.RuncCommitID |
|
| 161 |
+ if rv, err := exec.Command(DefaultRuntimeBinary, "--version").Output(); err == nil {
|
|
| 162 |
+ parts := strings.Split(strings.TrimSpace(string(rv)), "\n") |
|
| 163 |
+ if len(parts) == 3 {
|
|
| 164 |
+ parts = strings.Split(parts[1], ": ") |
|
| 165 |
+ if len(parts) == 2 {
|
|
| 166 |
+ v.RuncCommit.ID = strings.TrimSpace(parts[1]) |
|
| 167 |
+ } |
|
| 168 |
+ } |
|
| 169 |
+ } else {
|
|
| 170 |
+ logrus.Warnf("failed to retrieve %s version: %v", DefaultRuntimeBinary, err)
|
|
| 171 |
+ v.RuncCommit.ID = "N/A" |
|
| 172 |
+ } |
|
| 173 |
+ if v.RuncCommit.ID == "" {
|
|
| 174 |
+ logrus.Warnf("failed to retrieve %s version: unknown output format", DefaultRuntimeBinary)
|
|
| 175 |
+ v.RuncCommit.ID = "N/A" |
|
| 176 |
+ } |
|
| 177 |
+ |
|
| 178 |
+ v.InitCommit.Expected = dockerversion.InitCommitID |
|
| 179 |
+ if rv, err := exec.Command(DefaultInitBinary, "--version").Output(); err == nil {
|
|
| 180 |
+ parts := strings.Split(string(rv), " ") |
|
| 181 |
+ if len(parts) == 3 {
|
|
| 182 |
+ v.InitCommit.ID = strings.TrimSpace(parts[2]) |
|
| 183 |
+ } else {
|
|
| 184 |
+ logrus.Warnf("failed to retrieve %s version: unknown output format", DefaultInitBinary)
|
|
| 185 |
+ v.InitCommit.ID = "N/A" |
|
| 186 |
+ } |
|
| 187 |
+ } else {
|
|
| 188 |
+ logrus.Warnf("failed to retrieve %s version", DefaultInitBinary)
|
|
| 189 |
+ v.InitCommit.ID = "N/A" |
|
| 190 |
+ } |
|
| 150 | 191 |
} |
| 151 | 192 |
|
| 152 | 193 |
hostname := "" |
| ... | ... |
@@ -596,7 +596,7 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container) |
| 596 | 596 |
s.Process.Args = append([]string{"/dev/init", c.Path}, c.Args...)
|
| 597 | 597 |
var path string |
| 598 | 598 |
if daemon.configStore.InitPath == "" && c.HostConfig.InitPath == "" {
|
| 599 |
- path, err = exec.LookPath("docker-init")
|
|
| 599 |
+ path, err = exec.LookPath(DefaultInitBinary) |
|
| 600 | 600 |
if err != nil {
|
| 601 | 601 |
return err |
| 602 | 602 |
} |
| 603 | 603 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,8 @@ |
| 0 |
+#!/bin/sh |
|
| 1 |
+ |
|
| 2 |
+TOMLV_COMMIT=9baf8a8a9f2ed20a8e54160840c492f937eeaf9a |
|
| 3 |
+RUNC_COMMIT=ac031b5bf1cc92239461125f4c1ffb760522bbf2 |
|
| 4 |
+CONTAINERD_COMMIT=8517738ba4b82aff5662c97ca4627e7e4d03b531 |
|
| 5 |
+TINI_COMMIT=v0.13.0 |
|
| 6 |
+LIBNETWORK_COMMIT=0f534354b813003a754606689722fe253101bc4e |
|
| 7 |
+VNDR_COMMIT=f56bd4504b4fad07a357913687fb652ee54bb3b0 |
| ... | ... |
@@ -2,12 +2,7 @@ |
| 2 | 2 |
set -e |
| 3 | 3 |
set -x |
| 4 | 4 |
|
| 5 |
-TOMLV_COMMIT=9baf8a8a9f2ed20a8e54160840c492f937eeaf9a |
|
| 6 |
-RUNC_COMMIT=ac031b5bf1cc92239461125f4c1ffb760522bbf2 |
|
| 7 |
-CONTAINERD_COMMIT=8517738ba4b82aff5662c97ca4627e7e4d03b531 |
|
| 8 |
-TINI_COMMIT=v0.13.0 |
|
| 9 |
-LIBNETWORK_COMMIT=0f534354b813003a754606689722fe253101bc4e |
|
| 10 |
-VNDR_COMMIT=f56bd4504b4fad07a357913687fb652ee54bb3b0 |
|
| 5 |
+. $(dirname "$0")/binaries-commits |
|
| 11 | 6 |
|
| 12 | 7 |
RM_GOPATH=0 |
| 13 | 8 |
|
| ... | ... |
@@ -2,6 +2,8 @@ |
| 2 | 2 |
|
| 3 | 3 |
rm -rf autogen |
| 4 | 4 |
|
| 5 |
+source hack/dockerfile/binaries-commits |
|
| 6 |
+ |
|
| 5 | 7 |
cat > dockerversion/version_autogen.go <<DVEOF |
| 6 | 8 |
// +build autogen |
| 7 | 9 |
|
| ... | ... |
@@ -11,12 +13,16 @@ package dockerversion |
| 11 | 11 |
// Default build-time variable for library-import. |
| 12 | 12 |
// This file is overridden on build with build-time informations. |
| 13 | 13 |
const ( |
| 14 |
- GitCommit string = "$GITCOMMIT" |
|
| 15 |
- Version string = "$VERSION" |
|
| 16 |
- BuildTime string = "$BUILDTIME" |
|
| 17 |
- IAmStatic string = "${IAMSTATIC:-true}"
|
|
| 14 |
+ GitCommit string = "$GITCOMMIT" |
|
| 15 |
+ Version string = "$VERSION" |
|
| 16 |
+ BuildTime string = "$BUILDTIME" |
|
| 17 |
+ IAmStatic string = "${IAMSTATIC:-true}"
|
|
| 18 |
+ ContainerdCommitID string = "${CONTAINERD_COMMIT}"
|
|
| 19 |
+ RuncCommitID string = "${RUNC_COMMIT}"
|
|
| 20 |
+ InitCommitID string = "${TINI_COMMIT}"
|
|
| 18 | 21 |
) |
| 19 |
-// AUTOGENERATED FILE; see $BASH_SOURCE |
|
| 22 |
+ |
|
| 23 |
+// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen |
|
| 20 | 24 |
DVEOF |
| 21 | 25 |
|
| 22 | 26 |
# Compile the Windows resources into the sources |
| ... | ... |
@@ -36,7 +36,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 | 38 |
if daemonPlatform == "linux" {
|
| 39 |
- stringsToCheck = append(stringsToCheck, "Security Options:") |
|
| 39 |
+ stringsToCheck = append(stringsToCheck, "Init Binary:", "Security Options:", "containerd version:", "runc version:", "init version:") |
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 | 42 |
if DaemonIsLinux.Condition() {
|
| ... | ... |
@@ -28,6 +28,20 @@ type client struct {
|
| 28 | 28 |
liveRestore bool |
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
+// GetServerVersion returns the connected server version information |
|
| 32 |
+func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
|
|
| 33 |
+ resp, err := clnt.remote.apiClient.GetServerVersion(ctx, &containerd.GetServerVersionRequest{})
|
|
| 34 |
+ if err != nil {
|
|
| 35 |
+ return nil, err |
|
| 36 |
+ } |
|
| 37 |
+ |
|
| 38 |
+ sv := &ServerVersion{
|
|
| 39 |
+ GetServerVersionResponse: *resp, |
|
| 40 |
+ } |
|
| 41 |
+ |
|
| 42 |
+ return sv, nil |
|
| 43 |
+} |
|
| 44 |
+ |
|
| 31 | 45 |
// AddProcess is the handler for adding a process to an already running |
| 32 | 46 |
// container. It's called through docker exec. It returns the system pid of the |
| 33 | 47 |
// exec'd process. |
| ... | ... |
@@ -12,6 +12,20 @@ type client struct {
|
| 12 | 12 |
liveRestore bool |
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 |
+// GetServerVersion returns the connected server version information |
|
| 16 |
+func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
|
|
| 17 |
+ resp, err := clnt.remote.apiClient.GetServerVersion(ctx, &containerd.GetServerVersionRequest{})
|
|
| 18 |
+ if err != nil {
|
|
| 19 |
+ return nil, err |
|
| 20 |
+ } |
|
| 21 |
+ |
|
| 22 |
+ sv := &ServerVersion{
|
|
| 23 |
+ GetServerVersionResponse: *resp, |
|
| 24 |
+ } |
|
| 25 |
+ |
|
| 26 |
+ return sv, nil |
|
| 27 |
+} |
|
| 28 |
+ |
|
| 15 | 29 |
func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, specp Process, attachStdio StdioCallback) (int, error) {
|
| 16 | 30 |
return -1, nil |
| 17 | 31 |
} |
| ... | ... |
@@ -614,3 +614,7 @@ func (clnt *client) DeleteCheckpoint(containerID string, checkpointID string, ch |
| 614 | 614 |
func (clnt *client) ListCheckpoints(containerID string, checkpointDir string) (*Checkpoints, error) {
|
| 615 | 615 |
return nil, errors.New("Windows: Containers do not support checkpoints")
|
| 616 | 616 |
} |
| 617 |
+ |
|
| 618 |
+func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
|
|
| 619 |
+ return &ServerVersion{}, nil
|
|
| 620 |
+} |
| ... | ... |
@@ -3,6 +3,7 @@ package libcontainerd |
| 3 | 3 |
import ( |
| 4 | 4 |
"io" |
| 5 | 5 |
|
| 6 |
+ containerd "github.com/docker/containerd/api/grpc/types" |
|
| 6 | 7 |
"github.com/opencontainers/runtime-spec/specs-go" |
| 7 | 8 |
"golang.org/x/net/context" |
| 8 | 9 |
) |
| ... | ... |
@@ -33,6 +34,7 @@ type Backend interface {
|
| 33 | 33 |
|
| 34 | 34 |
// Client provides access to containerd features. |
| 35 | 35 |
type Client interface {
|
| 36 |
+ GetServerVersion(ctx context.Context) (*ServerVersion, error) |
|
| 36 | 37 |
Create(containerID string, checkpoint string, checkpointDir string, spec specs.Spec, attachStdio StdioCallback, options ...CreateOption) error |
| 37 | 38 |
Signal(containerID string, sig int) error |
| 38 | 39 |
SignalProcess(containerID string, processFriendlyName string, sig int) error |
| ... | ... |
@@ -65,3 +67,9 @@ type IOPipe struct {
|
| 65 | 65 |
Stderr io.ReadCloser |
| 66 | 66 |
Terminal bool // Whether stderr is connected on Windows |
| 67 | 67 |
} |
| 68 |
+ |
|
| 69 |
+// ServerVersion contains version information as retrieved from the |
|
| 70 |
+// server |
|
| 71 |
+type ServerVersion struct {
|
|
| 72 |
+ containerd.GetServerVersionResponse |
|
| 73 |
+} |