Преглед изворни кода

use ValidateContextDirectory to validate context

This commit makes the Docker cli client use ValidateContextDirectory
before attempting to create a tarball out of the context. This ensures
we avoid errors such as "unexpected EOF" during the upload of the
context.

This check is done before uploading any data and can save time and
bandwidth for remote Docker daemons.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
unclejack пре 11 година
родитељ
комит
33d5b38d62
1 измењених фајлова са 3 додато и 0 уклоњено
  1. 3 0
      api/client/commands.go

+ 3 - 0
api/client/commands.go

@@ -161,6 +161,9 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
 		if _, err = os.Stat(filename); os.IsNotExist(err) {
 		if _, err = os.Stat(filename); os.IsNotExist(err) {
 			return fmt.Errorf("no Dockerfile found in %s", cmd.Arg(0))
 			return fmt.Errorf("no Dockerfile found in %s", cmd.Arg(0))
 		}
 		}
+		if err = utils.ValidateContextDirectory(root); err != nil {
+			return fmt.Errorf("Error checking context is accessible: '%s'. Please check permissions and try again.", err)
+		}
 		context, err = archive.Tar(root, archive.Uncompressed)
 		context, err = archive.Tar(root, archive.Uncompressed)
 	}
 	}
 	var body io.Reader
 	var body io.Reader