mirror of https://github.com/docker/cli.git
Use the default registry even without --debug
Previously if the Docker engine was not running the behaviour of commands would vary depending on whether the --debug flag was provided. For example, consider `docker logout`: $ docker logout Not logged in to -- note the missing server URL $ docker --debug logout Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?). Using system default: https://index.docker.io/v1/ Not logged in to https://index.docker.io/v1/ -- note the server URL is present This patch makes only the debug printing conditional on the `--debug` flag, not the return value. Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
parent
f40f9c240a
commit
a82e6868cc
|
@ -29,11 +29,16 @@ func ElectAuthServer(ctx context.Context, cli Cli) string {
|
|||
// example a Linux client might be interacting with a Windows daemon, hence
|
||||
// the default registry URL might be Windows specific.
|
||||
serverAddress := registry.IndexServer
|
||||
if info, err := cli.Client().Info(ctx); err != nil && debug.IsEnabled() {
|
||||
if info, err := cli.Client().Info(ctx); err != nil {
|
||||
// Daemon is not responding so use system default.
|
||||
if debug.IsEnabled() {
|
||||
// Only report the warning if we're in debug mode to prevent nagging during engine initialization workflows
|
||||
fmt.Fprintf(cli.Err(), "Warning: failed to get default registry endpoint from daemon (%v). Using system default: %s\n", err, serverAddress)
|
||||
} else if info.IndexServerAddress == "" && debug.IsEnabled() {
|
||||
}
|
||||
} else if info.IndexServerAddress == "" {
|
||||
if debug.IsEnabled() {
|
||||
fmt.Fprintf(cli.Err(), "Warning: Empty registry endpoint from daemon. Using system default: %s\n", serverAddress)
|
||||
}
|
||||
} else {
|
||||
serverAddress = info.IndexServerAddress
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue