Created
June 13, 2017 11:18
-
-
Save ijc/ee11fd5a90f5c27005bfcec63dbac4f5 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 ( | |
"context" | |
"log" | |
"github.com/containerd/containerd" | |
"github.com/containerd/containerd/namespaces" | |
) | |
func main() { | |
sock := "/run/containerd/containerd.sock" | |
client, err := containerd.New(sock) | |
if err != nil { | |
log.Fatalf("creating containerd client") | |
} | |
ctx := namespaces.WithNamespace(context.Background(), "default") | |
image, err := client.Pull(ctx, "docker.io/library/nginx:alpine", containerd.WithPullUnpack) | |
if err != nil { | |
log.Fatalf("pulling container image: %s", err) | |
} | |
spec, err := containerd.GenerateSpec(containerd.WithImageConfig(ctx, image)) | |
if err != nil { | |
log.Fatalf("spec: %s\n", err) | |
} | |
_, err = client.NewContainer(ctx, "issue981", containerd.WithSpec(spec)) | |
if err != nil { | |
log.Fatalf("container: %s\n", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment