Skip to content

Instantly share code, notes, and snippets.

@AaronO
Created March 22, 2016 10:44
Show Gist options
  • Save AaronO/d706d9baa1a67043a637 to your computer and use it in GitHub Desktop.
Save AaronO/d706d9baa1a67043a637 to your computer and use it in GitHub Desktop.
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