Created
March 22, 2016 10:44
-
-
Save AaronO/d706d9baa1a67043a637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/fsouza/go-dockerclient" | |
) | |
func main() { | |
fail := func(args ...interface{}) { | |
fmt.Println(args...) | |
os.Exit(1) | |
} | |
if len(os.Args) < 2 { | |
fail("Please specify image to pull") | |
} | |
image := os.Args[1] | |
client, err := docker.NewClientFromEnv() | |
if err != nil { | |
fail("Docker error:", err) | |
} | |
repo, tag := docker.ParseRepositoryTag(image) | |
err = client.PullImage(docker.PullImageOptions{ | |
Repository: repo, | |
Tag: tag, | |
RawJSONStream: true, | |
OutputStream: os.Stdout, | |
}, docker.AuthConfiguration{}) | |
if err != nil { | |
fail("Failed to pull image:", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment