Skip to content

Commit cc5b0a2

Browse files
committed
cri: Don't use rel path for image volumes
Runc 1.1 throws a warning when using rel destination paths, and runc 1.2 is planning to thow an error (i.e. won't start the container). Let's just make this an abs path in the only place it might not be: the mounts created due to `VOLUME` directives in the Dockerfile. Signed-off-by: Rodrigo Campos <[email protected]> (cherry picked from commit 2d64ab8)
1 parent 4803c73 commit cc5b0a2

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/cri/server/container_create.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"errors"
2121
"fmt"
2222
"path/filepath"
23+
goruntime "runtime"
2324
"time"
2425

2526
"github.com/containerd/containerd"
@@ -304,6 +305,11 @@ func (c *criService) volumeMounts(containerRootDir string, criMounts []*runtime.
304305
}
305306
volumeID := util.GenerateID()
306307
src := filepath.Join(containerRootDir, "volumes", volumeID)
308+
if !filepath.IsAbs(dst) && goruntime.GOOS != "windows" {
309+
oldDst := dst
310+
dst = filepath.Join("/", dst)
311+
log.L.Debugf("Volume destination %q is not absolute, converted to %q", oldDst, dst)
312+
}
307313
// addOCIBindMounts will create these volumes.
308314
mounts = append(mounts, &runtime.Mount{
309315
ContainerPath: dst,

0 commit comments

Comments
 (0)