Last active
May 25, 2016 21:28
-
-
Save ranjib/d9f9798393a25971282de9e4093e49f2 to your computer and use it in GitHub Desktop.
docker image squashing
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
import( | |
"github.com/docker/engine-api/client" | |
"github.com/docker/engine-api/types" | |
) | |
func Squash() { | |
defaultHeaders := map[string]string{"User-Agent": "abc-1.0"} | |
cli, _ := client.NewClient("unix:///var/run/docker.sock", "v1.22", nil, defaultHeaders) | |
ctx := context.Background() | |
saveBody, _ := cli.ImageSave(ctx, []string{"image-id"}) | |
src := types.ImageImportSource{ | |
Source: saveBody, | |
SourceName: "-", | |
} | |
importOpts := types.ImageImportOptions{ | |
Message: "Squashing by foo", | |
Tag: "squashed", | |
Changes: []string{"CMD /bin/bash"}, | |
} | |
cli.ImageImport(ctx, src, "foo/abr", importOpts) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment