From d45c652e8393416d5a00eaa8864223b786c4182e Mon Sep 17 00:00:00 2001 From: John Howard Date: Tue, 3 Jan 2017 11:40:44 -0800 Subject: [PATCH] Windows to Linux build warning to stdout Signed-off-by: John Howard When building a Dockerfile from a Windows client on a Linux daemon, a "security warning" is printed on stderr. Having this warning printed on stderr makes it difficult to distinguish a failed build from one that's succeeding, and the only way to suppress the warning is through the -q option, which also suppresses every output. This change prints the warning on stdout, instead of stderr, to resolve this situation. --- cli/command/image/build.go | 2 +- integration-cli/docker_cli_build_test.go | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/cli/command/image/build.go b/cli/command/image/build.go index 1e4e8a267f..5d6e611406 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -334,7 +334,7 @@ func runBuild(dockerCli *command.DockerCli, options buildOptions) error { // Windows: show error message about modified file permissions if the // daemon isn't running Windows. if response.OSType != "windows" && runtime.GOOS == "windows" && !options.quiet { - fmt.Fprintln(dockerCli.Err(), `SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.`) + fmt.Fprintln(dockerCli.Out(), `SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.`) } // Everything worked so if -q was provided the output from the daemon diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 5dd4fc4c08..c97582c734 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -4644,23 +4644,20 @@ func (s *DockerSuite) TestBuildStderr(c *check.C) { // This test just makes sure that no non-error output goes // to stderr name := "testbuildstderr" - _, _, stderr, err := buildImageWithStdoutStderr(name, + _, stdout, stderr, err := buildImageWithStdoutStderr(name, "FROM busybox\nRUN echo one", true) if err != nil { c.Fatal(err) } - if runtime.GOOS == "windows" && - daemonPlatform != "windows" { - // Windows to non-Windows should have a security warning - if !strings.Contains(stderr, "SECURITY WARNING:") { - c.Fatalf("Stderr contains unexpected output: %q", stderr) - } - } else { - // Other platform combinations should have no stderr written too - if stderr != "" { - c.Fatalf("Stderr should have been empty, instead it's: %q", stderr) - } + // Windows to non-Windows should have a security warning + if runtime.GOOS == "windows" && daemonPlatform != "windows" && !strings.Contains(stdout, "SECURITY WARNING:") { + c.Fatalf("Stdout contains unexpected output: %q", stdout) + } + + // Stderr should always be empty + if stderr != "" { + c.Fatalf("Stderr should have been empty, instead it's: %q", stderr) } }