DockerCLI/cli/command/system
Sebastiaan van Stijn 9dc54f3fbe
info: don't print server info if we failed to connect
Before this patch, the Server output would be printed even if we failed to
connect (including WARNINGS):

```bash
docker -H tcp://127.0.0.1:2375 info
Cannot connect to the Docker daemon at tcp://127.0.0.1:2375. Is the docker daemon running?
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2)
  compose: Docker Compose (Docker Inc., v2.4.1)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Plugins:
  Volume:
  Network:
  Log:
 Swarm:
  NodeID:
  Is Manager: false
  Node Address:
 CPUs: 0
 Total Memory: 0B
 Docker Root Dir:
 Debug Mode: false
 Experimental: false
 Live Restore Enabled: false

WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
WARNING: No cpu shares support
WARNING: No cpuset support
WARNING: IPv4 forwarding is disabled
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
ERROR: Cannot connect to the Docker daemon at tcp://127.0.0.1:2375. Is the docker daemon running?
errors pretty printing info
```

With this patch;

```bash
docker -H tcp://127.0.0.1:2375 info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2)
  compose: Docker Compose (Docker Inc., v2.4.1)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
ERROR: Cannot connect to the Docker daemon at tcp://127.0.0.1:2375. Is the docker daemon running?
errors pretty printing info
```

And if a custom format is used:

```bash
docker -H tcp://127.0.0.1:2375 info --format '{{.Containers}}'
Cannot connect to the Docker daemon at tcp://127.0.0.1:2375. Is the docker daemon running?
0
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-10 12:13:03 +02:00
..
testdata remove "Experimental" client field from "docker version" 2022-04-08 15:48:00 +02:00
client_test.go Switch from x/net/context to context 2018-05-11 16:49:43 -07:00
cmd.go Revert "Disable `docker system dial-stdio` on Windows" 2019-03-12 14:57:52 +00:00
df.go Update list commands with better format flag description 2022-03-15 15:35:53 +01:00
dial_stdio.go dial-stdio: fix goroutine leakage 2019-03-22 20:22:00 +09:00
events.go cli/command/system: remove deprecated io/ioutil 2022-02-25 15:42:11 +01:00
info.go info: don't print server info if we failed to connect 2022-05-10 12:13:03 +02:00
info_test.go linting: fix incorrectly formatted errors (revive) 2022-03-28 10:37:25 +02:00
inspect.go Output compact JSON by default for --format=json 2022-03-15 15:42:35 +01:00
prune.go Replace vbom.ml/util with fvbommel/sortorder 2020-08-28 15:35:42 +02:00
prune_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
version.go use our own version of text/tabwriter 2022-04-25 15:01:41 +02:00
version_test.go remove "Experimental" client field from "docker version" 2022-04-08 15:48:00 +02:00