Merge pull request #2573 from lifubang/relativepathforrootfs

support relative rootfs path in ctr
This commit is contained in:
Michael Crosby 2018-08-27 10:25:25 -04:00 committed by GitHub
commit 6b00aaaf20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,7 @@ package run
import ( import (
gocontext "context" gocontext "context"
"path/filepath"
"strings" "strings"
"github.com/containerd/containerd" "github.com/containerd/containerd"
@ -61,7 +62,11 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
opts = append(opts, withMounts(context)) opts = append(opts, withMounts(context))
if context.Bool("rootfs") { if context.Bool("rootfs") {
opts = append(opts, oci.WithRootFSPath(ref)) rootfs, err := filepath.Abs(ref)
if err != nil {
return nil, err
}
opts = append(opts, oci.WithRootFSPath(rootfs))
} else { } else {
snapshotter := context.String("snapshotter") snapshotter := context.String("snapshotter")
image, err := client.GetImage(ctx, ref) image, err := client.GetImage(ctx, ref)