Volume subpath silently fails
services:
foo:
image: ubuntu
volumes:
- type: volume
source: bar
volume: { subpath: baz }
target: /baz
From https://github.com/moby/swarmkit/blob/master/swarmd/dockerexec/container.go#L338-L343:
if m.VolumeOptions != nil {
mount.VolumeOptions = &enginemount.VolumeOptions{
NoCopy: m.VolumeOptions.NoCopy,
// TODO: uncomment after 26.0 vendor
// Subpath: m.VolumeOptions.Subpath,
}
Has Docker 26.0 been vendored? If so, please enable volume subpath support! If not, please emit an error message.
https://github.com/docker/cli/pull/5833 seems related.
It would be great to have subpath support in Swarm!
I just tested subpath support with Docker v29.0.2: it works now for swarm services as well.
This is the compose file I used for testing:
services:
test:
image: alpine
command: ls -lR /mnt/nfs
deploy:
restart_policy:
condition: on-failure
volumes:
- type: volume
source: nfsv4-subpath-test
target: /mnt/nfs
volume:
nocopy: true
subpath: template
volumes:
nfsv4-subpath-test:
driver_opts:
type: nfs
o: addr=192.168.200.19,nfsvers=4
device: :/volume1/pve
My NAS has a nfs export to /volume1/pve, which has a subfolder called template. When the stack is deployed, the service logs show the directory content of /volume1/pve/template.
Looks like this issue was solved, and forgotten to be closed.