volumes: Implement subpath mount

`VolumeOptions` now has a `Subpath` field which allows to specify a path
relative to the volume that should be mounted as a destination.

Symlinks are supported, but they cannot escape the base volume
directory.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2023-06-09 20:43:45 +02:00
parent f2e1105056
commit bfb810445c
20 changed files with 727 additions and 30 deletions

View File

@@ -164,11 +164,12 @@ func (daemon *Daemon) containerStart(ctx context.Context, daemonCfg *configStore
return err
}
m, err := daemon.setupMounts(container)
m, cleanup, err := daemon.setupMounts(container)
if err != nil {
return err
}
mnts = append(mnts, m...)
defer cleanup()
spec, err := daemon.createSpec(ctx, daemonCfg, container, mnts)
if err != nil {