Skip to content

Commit

Permalink
cri: Don't use rel path for image volumes
Browse files Browse the repository at this point in the history
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 <rodrigoca@microsoft.com>
(cherry picked from commit 2d64ab8)
  • Loading branch information
rata committed Aug 7, 2023
1 parent 4803c73 commit cc5b0a2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/cri/server/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"path/filepath"
goruntime "runtime"
"time"

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

0 comments on commit cc5b0a2

Please sign in to comment.