// buildImage invokes a docker build on a particular directory func buildImage(client DockerClient, dir string, noCache bool, tag string, tar tar.Tar, pullAuth *docker.AuthConfigurations, forcePull bool) error { tarFile, err := tar.CreateTarFile("", dir) if err != nil { return err } tarStream, err := os.Open(tarFile) if err != nil { return err } defer tarStream.Close() opts := docker.BuildImageOptions{ Name: tag, RmTmpContainer: true, OutputStream: os.Stdout, InputStream: tarStream, NoCache: noCache, Pull: forcePull, } if pullAuth != nil { opts.AuthConfigs = *pullAuth } return client.BuildImage(opts) }