containerd / containerd/nerdctl

using volumes-from mount additional folders

Open
#2,667 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
10.4k
Forks
826
Avg merge
1d 23h
Merged PRs (30d)
44

Description

### Description

when I used the `volumes-from` command, I only needed to mount the volume folder of other containers, but I found that in the source code
```
if idMatch || nameMatch {
if av, found := ls[labels.AnonymousVolumes]; found {
err = json.Unmarshal([]byte(av), &vfAnonVolumes)
if err != nil {
return nil, nil, nil, err
}
}
if m, found := ls[labels.Mounts]; found {
err = json.Unmarshal([]byte(m), &vfMountPoints)
if err != nil {
return nil, nil, nil, err
}
}

ps := processeds(vfMountPoints)
s, err := c.Spec(ctx)
if err != nil {
return nil, nil, nil, err
}
opts = append(opts, withMounts(s.Mounts))
anonVolumes = append(anonVolumes, vfAnonVolumes...)
mountPoints = append(mountPoints, ps...)
}
```
To my knowledge, s.Mount also has directories such as "/dev/" and "/dev/shm" in addition to anonymous and other mounted directories. Changing the code(`opts = append(opts, withMounts(s.Mounts))`) to append all mounts to the new container will overwrite the directory I want to mount when creating the container(such as/dev/shm). Is this reasonable?

my skills and English are not very good, please forgive me

### Steps to reproduce the issue

1.
2.
3.

### Describe the results you received and expected

using the `volumes-form` command will not mount extra directories

### What version of nerdctl are you using?

any

### Are you using a variant of nerdctl? (e.g., Rancher Desktop)

None

### Host information

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.