Created
April 22, 2015 14:43
-
-
Save brk3/185791837fa24e5fcfee to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
"archive/tar" | |
"bytes" | |
"github.com/fsouza/go-dockerclient" | |
"log" | |
"time" | |
) | |
func main() { | |
client, err := docker.NewClient("unix:///var/run/docker.sock") | |
if err != nil { | |
log.Fatal(err) | |
} | |
t := time.Now() | |
inputbuf, outputbuf := bytes.NewBuffer(nil), bytes.NewBuffer(nil) | |
tr := tar.NewWriter(inputbuf) | |
tr.WriteHeader(&tar.Header{Name: "Dockerfile", Size: 10, ModTime: t, AccessTime: t, ChangeTime: t}) | |
tr.Write([]byte("FROM fedora:20\n")) | |
tr.Close() | |
opts := docker.BuildImageOptions{ | |
Name: "test", | |
InputStream: inputbuf, | |
OutputStream: outputbuf, | |
} | |
if err := client.BuildImage(opts); err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment