From 0bcc95e4a12233c3ea28a45e0b44123b03cbd05d Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Wed, 4 Oct 2017 22:43:09 +0000 Subject: [PATCH] Skip not exist image volume directory. Signed-off-by: Lantao Liu --- pkg/opts/container.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/opts/container.go b/pkg/opts/container.go index 49bc12464..ea7abb9b0 100644 --- a/pkg/opts/container.go +++ b/pkg/opts/container.go @@ -57,7 +57,15 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts { defer unix.Unmount(root, 0) // nolint: errcheck for host, volume := range volumeMounts { - if err := copyExistingContents(filepath.Join(root, volume), host); err != nil { + src := filepath.Join(root, volume) + if _, err := os.Stat(src); err != nil { + if os.IsNotExist(err) { + // Skip copying directory if it does not exist. + continue + } + return errors.Wrap(err, "stat volume in rootfs") + } + if err := copyExistingContents(src, host); err != nil { return errors.Wrap(err, "taking runtime copy of volume") } }