Compare commits

..

15 Commits

Author SHA1 Message Date
8108357bcb Merge pull request #6662 from dvdksn/doc-update-http-proxy-link
Some checks failed
build / prepare-plugins (push) Has been cancelled
build / plugins (push) Has been cancelled
codeql / codeql (push) Has been cancelled
e2e / tests (alpine, 25, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 25, local) (push) Has been cancelled
e2e / tests (alpine, 27, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 27, local) (push) Has been cancelled
e2e / tests (alpine, 28, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 28, local) (push) Has been cancelled
e2e / tests (alpine, 29-rc, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 29-rc, local) (push) Has been cancelled
e2e / tests (debian, 25, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 25, local) (push) Has been cancelled
e2e / tests (debian, 27, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 27, local) (push) Has been cancelled
e2e / tests (debian, 28, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 28, local) (push) Has been cancelled
e2e / tests (debian, 29-rc, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 29-rc, local) (push) Has been cancelled
test / ctn (push) Has been cancelled
test / host (macos-14) (push) Has been cancelled
test / host (macos-15) (push) Has been cancelled
test / host (macos-15-intel) (push) Has been cancelled
validate / validate (lint) (push) Has been cancelled
validate / validate (shellcheck) (push) Has been cancelled
validate / validate (update-authors) (push) Has been cancelled
validate / validate (validate-vendor) (push) Has been cancelled
validate / validate-md (push) Has been cancelled
validate / validate-make (manpages) (push) Has been cancelled
validate / validate-make (yamldocs) (push) Has been cancelled
chore: update link/linktext to dockerd proxy config
2025-11-17 11:19:50 +01:00
3a842587f9 chore: update link/linktext to dockerd proxy config
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2025-11-17 11:00:04 +01:00
eedd9698e9 Merge pull request #6659 from vvoland/fix-system-version
Some checks failed
build / prepare-plugins (push) Has been cancelled
build / plugins (push) Has been cancelled
codeql / codeql (push) Has been cancelled
e2e / tests (alpine, 25, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 25, local) (push) Has been cancelled
e2e / tests (alpine, 27, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 27, local) (push) Has been cancelled
e2e / tests (alpine, 28, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 28, local) (push) Has been cancelled
e2e / tests (alpine, 29-rc, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 29-rc, local) (push) Has been cancelled
e2e / tests (debian, 25, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 25, local) (push) Has been cancelled
e2e / tests (debian, 27, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 27, local) (push) Has been cancelled
e2e / tests (debian, 28, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 28, local) (push) Has been cancelled
e2e / tests (debian, 29-rc, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 29-rc, local) (push) Has been cancelled
test / ctn (push) Has been cancelled
test / host (macos-14) (push) Has been cancelled
test / host (macos-15) (push) Has been cancelled
test / host (macos-15-intel) (push) Has been cancelled
validate / validate (lint) (push) Has been cancelled
validate / validate (shellcheck) (push) Has been cancelled
validate / validate (update-authors) (push) Has been cancelled
validate / validate (validate-vendor) (push) Has been cancelled
validate / validate-md (push) Has been cancelled
validate / validate-make (manpages) (push) Has been cancelled
validate / validate-make (yamldocs) (push) Has been cancelled
cli/command/system: Fix missing components in version output
2025-11-13 22:27:39 +01:00
dd2c493825 cli/command/system: Fix missing components in version output
The `Components` weren't actually copied to the output struct.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-13 21:19:41 +01:00
67cef775fe Merge pull request #6658 from vvoland/img-list-all-dangling
image/tree: Only show untagged images when --all flag is used
2025-11-13 20:53:26 +01:00
207bf52c27 image/tree: Only show untagged images when --all flag is used
In non-expanded view, untagged images should only be displayed when the
--all flag is explicitly provided by the user.

Previously, untagged images were accidentally always shown in the
non-expanded view regardless of the --all flag setting.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-13 20:23:42 +01:00
2cfd9df568 Merge pull request #6654 from vvoland/img-list-nocolor
image/tree: Respect NO_COLOR env variable
2025-11-13 15:10:10 +01:00
be9e6308f5 image/tree: Respect NO_COLOR env variable
Do not use the fancy colored output if NO_COLOR variable is set to 1
following the https://no-color.org/ convention.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-13 14:56:27 +01:00
88e324150b Merge pull request #6657 from vvoland/img-list-nonexpanded-untagged
image/tree: Fix untagged images in non-expanded view
2025-11-13 13:20:46 +01:00
2ae51e2d69 Merge pull request #6656 from vvoland/img-list-notty-width
image/tree: Don't limit name width if non tty
2025-11-13 13:19:30 +01:00
ed281ddf52 image/list: Print legend only if limiting width
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-13 13:00:02 +01:00
aa5d00a3a4 image/tree: Don't limit name width if non tty
Previously when no terminal was attached the width was assumed to be 80.
This is too short for most image names which truncated the names when
output was redirect (for example to `grep`).

This disabled the name truncation if the terminal width can't be
determined.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-13 12:59:46 +01:00
b66b93130c image/tree: Fix untagged images in non-expanded view
In the expanded view there is a separate image entry per each tag.

Fix a bug which caused no entry to be added for untagged images.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-13 12:47:24 +01:00
c44e8a0727 Merge pull request #6648 from thaJeztah/cli_version_json_format
cli/command/system: define struct for formatting version
2025-11-12 18:09:53 +01:00
bff56f0493 cli/command/system: define struct for formatting version
The client.ServerVersion method in the moby/client module defines
an output struct that's separate from the API response. These output
structs are not designed to be marshaled as JSON, but the CLI depended
on them defining `json` labels, which it used to format the output
as JSON (`docker version --format=json`); as a result, the JSON output
changed in docker v29, as it would now use the naming based on the Go
struct's fields (`APIVersion` instead of `ApiVersion`).

In future, we should consider having a `--raw` (or similar) option for
the CLI to print API responses as-is, instead of using client structs
or CLI structs for this (this would also make sure the JSON output does
not inherit client-side formatting of fields).

For now, let's create a struct for formatting the output, similar to what
we do for the client-side information.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-12 14:57:13 +01:00
13 changed files with 166 additions and 78 deletions

View File

@ -1,2 +1 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA

View File

@ -1,2 +1 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA

View File

@ -1,2 +1 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA

View File

@ -1,2 +1 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA

View File

@ -111,6 +111,13 @@ func runTree(ctx context.Context, dockerCLI command.Cli, opts treeOptions) (int,
continue
}
if opts.all && len(sortedTags) == 0 {
view.images = append(view.images, topImage{
Details: topDetails,
Children: children,
created: img.Created,
})
}
for _, tag := range sortedTags {
view.images = append(view.images, topImage{
Names: []string{tag},
@ -230,11 +237,11 @@ func printImageTree(outs command.Streams, view treeView) {
}
out := tui.NewOutput(outs.Out())
isTerm := out.IsTerminal()
_, width := out.GetTtySize()
if width == 0 {
width = 80
}
if width < 20 {
limitWidth := width == 0
if isTerm && width < 20 {
width = 20
}
@ -243,9 +250,10 @@ func printImageTree(outs command.Streams, view treeView) {
untaggedColor := out.Color(tui.ColorTertiary)
titleColor := out.Color(tui.ColorTitle)
isTerm := out.IsTerminal()
out.Println(generateLegend(out, width))
// Legend is right-aligned, so don't print it if the width is unlimited
if !limitWidth {
out.Println(generateLegend(out, width))
}
possibleChips := getPossibleChips(view)
columns := []imgColumn{
@ -284,7 +292,7 @@ func printImageTree(outs command.Streams, view treeView) {
Width: func() int {
maxChipsWidth := 0
for _, chip := range possibleChips {
s := chip.String(isTerm)
s := out.Sprint(chip)
l := tui.Width(s)
maxChipsWidth += l
}
@ -300,9 +308,9 @@ func printImageTree(outs command.Streams, view treeView) {
var b strings.Builder
for _, chip := range possibleChips {
if chip.check(d) {
b.WriteString(chip.String(isTerm))
b.WriteString(out.Sprint(chip))
} else {
b.WriteString(chipPlaceholder.String(isTerm))
b.WriteString(out.Sprint(chipPlaceholder))
}
}
return b.String()
@ -340,25 +348,27 @@ func printImageTree(outs command.Streams, view treeView) {
// to display their content.
func adjustColumns(width uint, columns []imgColumn, images []topImage) []imgColumn {
nameWidth := int(width)
for idx, h := range columns {
if h.Width == 0 {
continue
if nameWidth > 0 {
for idx, h := range columns {
if h.Width == 0 {
continue
}
d := h.Width
if idx > 0 {
d += columnSpacing
}
// If the first column gets too short, remove remaining columns
if nameWidth-d < 12 {
columns = columns[:idx]
break
}
nameWidth -= d
}
d := h.Width
if idx > 0 {
d += columnSpacing
}
// If the first column gets too short, remove remaining columns
if nameWidth-d < 12 {
columns = columns[:idx]
break
}
nameWidth -= d
}
// Try to make the first column as narrow as possible
widest := widestFirstColumnValue(columns, images)
if nameWidth > widest {
if width == 0 || nameWidth > widest {
nameWidth = widest
}
columns[0].Width = nameWidth

View File

@ -15,6 +15,7 @@ func TestPrintImageTreeAnsiTty(t *testing.T) {
stdoutTty bool
stderrTty bool
expectedAnsi bool
noColorEnv bool
}{
{
name: "non-terminal",
@ -80,6 +81,24 @@ func TestPrintImageTreeAnsiTty(t *testing.T) {
expectedAnsi: false,
},
{
name: "no-color-env",
stdinTty: false,
stdoutTty: false,
stderrTty: false,
noColorEnv: true,
expectedAnsi: false,
},
{
name: "no-color-env-terminal",
stdinTty: true,
stdoutTty: true,
stderrTty: true,
noColorEnv: true,
expectedAnsi: false,
},
}
mockView := treeView{
@ -115,6 +134,11 @@ func TestPrintImageTreeAnsiTty(t *testing.T) {
cli.In().SetIsTerminal(tc.stdinTty)
cli.Out().SetIsTerminal(tc.stdoutTty)
cli.Err().SetIsTerminal(tc.stderrTty)
if tc.noColorEnv {
t.Setenv("NO_COLOR", "1")
} else {
t.Setenv("NO_COLOR", "")
}
printImageTree(cli, mockView)
@ -123,9 +147,9 @@ func TestPrintImageTreeAnsiTty(t *testing.T) {
hasAnsi := strings.Contains(out, "\x1b[")
if tc.expectedAnsi {
assert.Check(t, hasAnsi, "Output should contain ANSI escape codes")
assert.Check(t, hasAnsi, "Output should contain ANSI escape codes, output: %s", out)
} else {
assert.Check(t, !hasAnsi, "Output should not contain ANSI escape codes")
assert.Check(t, !hasAnsi, "Output should not contain ANSI escape codes, output: %s", out)
}
})
}

View File

@ -1 +1 @@
{"Client":{"Version":"18.99.5-ce","ApiVersion":"1.38","DefaultAPIVersion":"1.38","GitCommit":"deadbeef","GoVersion":"go1.10.2","Os":"linux","Arch":"amd64","BuildTime":"Wed May 30 22:21:05 2018","Context":"my-context"},"Server":{"Platform":{"Name":"Docker Enterprise Edition (EE) 2.0"},"Version":"","APIVersion":"","MinAPIVersion":"","Os":"","Arch":"","Experimental":false,"Components":[{"Name":"Engine","Version":"17.06.2-ee-15","Details":{"ApiVersion":"1.30","Arch":"amd64","BuildTime":"Mon Jul 9 23:38:38 2018","Experimental":"false","GitCommit":"64ddfa6","GoVersion":"go1.8.7","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"Universal Control Plane","Version":"17.06.2-ee-15","Details":{"ApiVersion":"1.30","Arch":"amd64","BuildTime":"Mon Jul 2 21:24:07 UTC 2018","GitCommit":"4513922","GoVersion":"go1.9.4","MinApiVersion":"1.20","Os":"linux","Version":"3.0.3-tp2"}},{"Name":"Kubernetes","Version":"1.8+","Details":{"buildDate":"2018-04-26T16:51:21Z","compiler":"gc","gitCommit":"8d637aedf46b9c21dde723e29c645b9f27106fa5","gitTreeState":"clean","gitVersion":"v1.8.11-docker-8d637ae","goVersion":"go1.8.3","major":"1","minor":"8+","platform":"linux/amd64"}},{"Name":"Calico","Version":"v3.0.8","Details":{"cni":"v2.0.6","kube-controllers":"v2.0.5","node":"v3.0.8"}}]}}
{"Client":{"Version":"18.99.5-ce","ApiVersion":"1.38","DefaultAPIVersion":"1.38","GitCommit":"deadbeef","GoVersion":"go1.10.2","Os":"linux","Arch":"amd64","BuildTime":"Wed May 30 22:21:05 2018","Context":"my-context"},"Server":{"Platform":{"Name":"Docker Enterprise Edition (EE) 2.0"},"Version":"18.99.5-ce","ApiVersion":"1.30","MinAPIVersion":"1.12","Os":"linux","Arch":"amd64","Components":[{"Name":"Engine","Version":"17.06.2-ee-15","Details":{"ApiVersion":"1.30","Arch":"amd64","BuildTime":"Mon Jul 9 23:38:38 2018","Experimental":"false","GitCommit":"64ddfa6","GoVersion":"go1.8.7","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"Universal Control Plane","Version":"17.06.2-ee-15","Details":{"ApiVersion":"1.30","Arch":"amd64","BuildTime":"Mon Jul 2 21:24:07 UTC 2018","GitCommit":"4513922","GoVersion":"go1.9.4","MinApiVersion":"1.20","Os":"linux","Version":"3.0.3-tp2"}},{"Name":"Kubernetes","Version":"1.8+","Details":{"buildDate":"2018-04-26T16:51:21Z","compiler":"gc","gitCommit":"8d637aedf46b9c21dde723e29c645b9f27106fa5","gitTreeState":"clean","gitVersion":"v1.8.11-docker-8d637ae","goVersion":"go1.8.3","major":"1","minor":"8+","platform":"linux/amd64"}},{"Name":"Calico","Version":"v3.0.8","Details":{"cni":"v2.0.6","kube-controllers":"v2.0.5","node":"v3.0.8"}}],"GitCommit":"64ddfa6","GoVersion":"go1.8.7","KernelVersion":"v1.0.0","BuildTime":"Mon Jul 9 23:38:38 2018"}}

View File

@ -1 +1 @@
{"Client":{"Version":"18.99.5-ce","ApiVersion":"1.38","DefaultAPIVersion":"1.38","GitCommit":"deadbeef","GoVersion":"go1.10.2","Os":"linux","Arch":"amd64","BuildTime":"Wed May 30 22:21:05 2018","Context":"my-context"},"Server":{"Platform":{"Name":"Docker Enterprise Edition (EE) 2.0"},"Version":"","APIVersion":"","MinAPIVersion":"","Os":"","Arch":"","Experimental":false,"Components":[{"Name":"Engine","Version":"17.06.2-ee-15","Details":{"ApiVersion":"1.30","Arch":"amd64","BuildTime":"Mon Jul 9 23:38:38 2018","Experimental":"false","GitCommit":"64ddfa6","GoVersion":"go1.8.7","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"Universal Control Plane","Version":"17.06.2-ee-15","Details":{"ApiVersion":"1.30","Arch":"amd64","BuildTime":"Mon Jul 2 21:24:07 UTC 2018","GitCommit":"4513922","GoVersion":"go1.9.4","MinApiVersion":"1.20","Os":"linux","Version":"3.0.3-tp2"}},{"Name":"Kubernetes","Version":"1.8+","Details":{"buildDate":"2018-04-26T16:51:21Z","compiler":"gc","gitCommit":"8d637aedf46b9c21dde723e29c645b9f27106fa5","gitTreeState":"clean","gitVersion":"v1.8.11-docker-8d637ae","goVersion":"go1.8.3","major":"1","minor":"8+","platform":"linux/amd64"}},{"Name":"Calico","Version":"v3.0.8","Details":{"cni":"v2.0.6","kube-controllers":"v2.0.5","node":"v3.0.8"}}]}}
{"Client":{"Version":"18.99.5-ce","ApiVersion":"1.38","DefaultAPIVersion":"1.38","GitCommit":"deadbeef","GoVersion":"go1.10.2","Os":"linux","Arch":"amd64","BuildTime":"Wed May 30 22:21:05 2018","Context":"my-context"},"Server":{"Platform":{"Name":"Docker Enterprise Edition (EE) 2.0"},"Version":"18.99.5-ce","ApiVersion":"1.30","MinAPIVersion":"1.12","Os":"linux","Arch":"amd64","Components":[{"Name":"Engine","Version":"17.06.2-ee-15","Details":{"ApiVersion":"1.30","Arch":"amd64","BuildTime":"Mon Jul 9 23:38:38 2018","Experimental":"false","GitCommit":"64ddfa6","GoVersion":"go1.8.7","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"Universal Control Plane","Version":"17.06.2-ee-15","Details":{"ApiVersion":"1.30","Arch":"amd64","BuildTime":"Mon Jul 2 21:24:07 UTC 2018","GitCommit":"4513922","GoVersion":"go1.9.4","MinApiVersion":"1.20","Os":"linux","Version":"3.0.3-tp2"}},{"Name":"Kubernetes","Version":"1.8+","Details":{"buildDate":"2018-04-26T16:51:21Z","compiler":"gc","gitCommit":"8d637aedf46b9c21dde723e29c645b9f27106fa5","gitTreeState":"clean","gitVersion":"v1.8.11-docker-8d637ae","goVersion":"go1.8.3","major":"1","minor":"8+","platform":"linux/amd64"}},{"Name":"Calico","Version":"v3.0.8","Details":{"cni":"v2.0.6","kube-controllers":"v2.0.5","node":"v3.0.8"}}],"GitCommit":"64ddfa6","GoVersion":"go1.8.7","KernelVersion":"v1.0.0","BuildTime":"Mon Jul 9 23:38:38 2018"}}

View File

@ -6,6 +6,7 @@ import (
"io"
"runtime"
"sort"
"strconv"
"text/template"
"time"
@ -63,7 +64,7 @@ type versionOptions struct {
// versionInfo contains version information of both the Client, and Server
type versionInfo struct {
Client clientVersion
Server *client.ServerVersionResult
Server *serverVersion
}
type platformInfo struct {
@ -83,6 +84,26 @@ type clientVersion struct {
Context string `json:"Context"`
}
// serverVersion contains information about the Docker server host.
// it's the client-side presentation of [client.ServerVersionResult].
type serverVersion struct {
Platform client.PlatformInfo `json:",omitempty"` // Platform is the platform (product name) the server is running on.
Version string `json:"Version"` // Version is the version of the daemon.
APIVersion string `json:"ApiVersion"` // APIVersion is the highest API version supported by the server.
MinAPIVersion string `json:"MinAPIVersion,omitempty"` // MinAPIVersion is the minimum API version the server supports.
Os string `json:"Os"` // Os is the operating system the server runs on.
Arch string `json:"Arch"` // Arch is the hardware architecture the server runs on.
Components []system.ComponentVersion `json:"Components,omitempty"` // Components contains version information for the components making up the server.
// The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility
GitCommit string `json:"GitCommit,omitempty"`
GoVersion string `json:"GoVersion,omitempty"`
KernelVersion string `json:"KernelVersion,omitempty"`
Experimental bool `json:"Experimental,omitempty"`
BuildTime string `json:"BuildTime,omitempty"`
}
// newClientVersion constructs a new clientVersion. If a dockerCLI is
// passed as argument, additional information is included (API version),
// which may invoke an API connection. Pass nil to omit the additional
@ -107,6 +128,49 @@ func newClientVersion(contextName string, dockerCli command.Cli) clientVersion {
return v
}
func newServerVersion(sv client.ServerVersionResult) *serverVersion {
out := &serverVersion{
Platform: sv.Platform,
Version: sv.Version,
APIVersion: sv.APIVersion,
MinAPIVersion: sv.MinAPIVersion,
Os: sv.Os,
Arch: sv.Arch,
Experimental: sv.Experimental, //nolint:staticcheck // ignore deprecated field.
Components: make([]system.ComponentVersion, 0, len(sv.Components)),
}
foundEngine := false
for _, component := range sv.Components {
if component.Name == "Engine" {
foundEngine = true
buildTime, ok := component.Details["BuildTime"]
if ok {
component.Details["BuildTime"] = reformatDate(buildTime)
}
out.GitCommit = component.Details["GitCommit"]
out.GoVersion = component.Details["GoVersion"]
out.KernelVersion = component.Details["KernelVersion"]
out.Experimental = func() bool { b, _ := strconv.ParseBool(component.Details["Experimental"]); return b }()
out.BuildTime = reformatDate(component.Details["BuildTime"])
}
out.Components = append(out.Components, component)
}
if !foundEngine {
out.Components = append(out.Components, system.ComponentVersion{
Name: "Engine",
Version: sv.Version,
Details: map[string]string{
"ApiVersion": sv.APIVersion,
"MinAPIVersion": sv.MinAPIVersion,
"Os": sv.Os,
"Arch": sv.Arch,
},
})
}
return out
}
// newVersionCommand creates a new cobra.Command for `docker version`
func newVersionCommand(dockerCLI command.Cli) *cobra.Command {
var opts versionOptions
@ -138,14 +202,14 @@ func reformatDate(buildTime string) string {
}
func arch() string {
arch := runtime.GOARCH
out := runtime.GOARCH
if rosetta.Enabled() {
arch += " (rosetta)"
out += " (rosetta)"
}
return arch
return out
}
func runVersion(ctx context.Context, dockerCli command.Cli, opts *versionOptions) error {
func runVersion(ctx context.Context, dockerCLI command.Cli, opts *versionOptions) error {
var err error
tmpl, err := newVersionTemplate(opts.format)
if err != nil {
@ -153,36 +217,13 @@ func runVersion(ctx context.Context, dockerCli command.Cli, opts *versionOptions
}
vd := versionInfo{
Client: newClientVersion(dockerCli.CurrentContext(), dockerCli),
Client: newClientVersion(dockerCLI.CurrentContext(), dockerCLI),
}
sv, err := dockerCli.Client().ServerVersion(ctx, client.ServerVersionOptions{})
sv, err := dockerCLI.Client().ServerVersion(ctx, client.ServerVersionOptions{})
if err == nil {
vd.Server = &sv
foundEngine := false
for _, component := range sv.Components {
if component.Name == "Engine" {
foundEngine = true
buildTime, ok := component.Details["BuildTime"]
if ok {
component.Details["BuildTime"] = reformatDate(buildTime)
}
}
}
if !foundEngine {
vd.Server.Components = append(vd.Server.Components, system.ComponentVersion{
Name: "Engine",
Version: sv.Version,
Details: map[string]string{
"ApiVersion": sv.APIVersion,
"MinAPIVersion": sv.MinAPIVersion,
"Os": sv.Os,
"Arch": sv.Arch,
},
})
}
vd.Server = newServerVersion(sv)
}
if err2 := prettyPrintVersion(dockerCli.Out(), vd, tmpl); err2 != nil && err == nil {
if err2 := prettyPrintVersion(dockerCLI.Out(), vd, tmpl); err2 != nil && err == nil {
err = err2
}
return err

View File

@ -47,8 +47,18 @@ func TestVersionFormat(t *testing.T) {
BuildTime: "Wed May 30 22:21:05 2018",
Context: "my-context",
},
Server: &client.ServerVersionResult{
Platform: client.PlatformInfo{Name: "Docker Enterprise Edition (EE) 2.0"},
Server: &serverVersion{
Platform: client.PlatformInfo{Name: "Docker Enterprise Edition (EE) 2.0"},
Version: "18.99.5-ce",
APIVersion: "1.30",
MinAPIVersion: "1.12",
Os: "linux",
Arch: "amd64",
GitCommit: "64ddfa6",
GoVersion: "go1.8.7",
KernelVersion: "v1.0.0",
Experimental: false,
BuildTime: "Mon Jul 9 23:38:38 2018",
Components: []system.ComponentVersion{
{
Name: "Engine",

View File

@ -130,6 +130,8 @@ line:
| `DOCKER_TLS` | Enable TLS for connections made by the `docker` CLI (equivalent of the `--tls` command-line option). Set to a non-empty value to enable TLS. Note that TLS is enabled automatically if any of the other TLS options are set. |
| `DOCKER_TLS_VERIFY` | When set Docker uses TLS and verifies the remote. This variable is used both by the `docker` CLI and the [`dockerd` daemon](https://docs.docker.com/reference/cli/dockerd/) |
| `BUILDKIT_PROGRESS` | Set type of progress output (`auto`, `plain`, `tty`, `rawjson`) when [building](https://docs.docker.com/reference/cli/docker/image/build/) with [BuildKit backend](https://docs.docker.com/build/buildkit/). Use plain to show container output (default `auto`). |
| `NO_COLOR` | Disable any ANSI escape codes in the output in accordance with https://no-color.org/
|
Because Docker is developed using Go, you can also use any environment
variables used by the Go runtime. In particular, you may find these useful:
@ -317,8 +319,8 @@ be set for each environment:
These settings are used to configure proxy settings for containers only, and not
used as proxy settings for the `docker` CLI or the `dockerd` daemon. Refer to the
[environment variables](#environment-variables) and [HTTP/HTTPS proxy](https://docs.docker.com/engine/daemon/proxy/#httphttps-proxy)
sections for configuring proxy settings for the CLI and daemon.
[environment variables](#environment-variables) section and the [Daemon proxy configuration](https://docs.docker.com/engine/daemon/proxy/)
guide for configuring proxy settings for the CLI and daemon.
> [!WARNING]
> Proxy settings may contain sensitive information (for example, if the proxy

View File

@ -28,7 +28,7 @@ func withHeader(header Str) noteOptions {
}
func (o Output) printNoteWithOptions(format string, args []any, opts ...noteOptions) {
if o.isTerminal {
if !o.noColor {
// TODO: Handle all flags
format = strings.ReplaceAll(format, "--platform", ColorFlag.Apply("--platform"))
}
@ -51,7 +51,7 @@ func (o Output) printNoteWithOptions(format string, args []any, opts ...noteOpti
}
l := line
if o.isTerminal {
if !o.noColor {
l = aec.Italic.Apply(l)
}
_, _ = fmt.Fprintln(o, l)

View File

@ -5,6 +5,7 @@ package tui
import (
"fmt"
"os"
"github.com/docker/cli/cli/streams"
"github.com/morikuni/aec"
@ -12,7 +13,7 @@ import (
type Output struct {
*streams.Out
isTerminal bool
noColor bool
}
type terminalPrintable interface {
@ -20,24 +21,28 @@ type terminalPrintable interface {
}
func NewOutput(out *streams.Out) Output {
noColor := !out.IsTerminal()
if os.Getenv("NO_COLOR") != "" {
noColor = true
}
return Output{
Out: out,
isTerminal: out.IsTerminal(),
Out: out,
noColor: noColor,
}
}
func (o Output) Color(clr aec.ANSI) aec.ANSI {
if o.isTerminal {
return clr
if o.noColor {
return ColorNone
}
return ColorNone
return clr
}
func (o Output) Sprint(all ...any) string {
var out []any
for _, p := range all {
if s, ok := p.(terminalPrintable); ok {
out = append(out, s.String(o.isTerminal))
out = append(out, s.String(!o.noColor))
} else {
out = append(out, p)
}
@ -47,7 +52,7 @@ func (o Output) Sprint(all ...any) string {
func (o Output) PrintlnWithColor(clr aec.ANSI, args ...any) {
msg := o.Sprint(args...)
if o.isTerminal {
if !o.noColor {
msg = clr.Apply(msg)
}
_, _ = fmt.Fprintln(o.Out, msg)