mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-04 15:58:39 +00:00
Fix create volume in a directory which is a symbolic link
Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
+6
-3
@@ -189,10 +189,13 @@ func (container *Container) parseVolumeMountConfig() (map[string]*Mount, error)
|
||||
if _, exists := container.Volumes[path]; exists {
|
||||
continue
|
||||
}
|
||||
|
||||
if stat, err := os.Stat(filepath.Join(container.basefs, path)); err == nil {
|
||||
realpath, err := symlink.FollowSymlinkInScope(filepath.Join(container.basefs, path), container.basefs)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to evaluate the absolute path of symlink")
|
||||
}
|
||||
if stat, err := os.Stat(realpath); err == nil {
|
||||
if !stat.IsDir() {
|
||||
return nil, fmt.Errorf("file exists at %s, can't create volume there")
|
||||
return nil, fmt.Errorf("file exists at %s, can't create volume there", realpath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user