swarmkit icon indicating copy to clipboard operation
swarmkit copied to clipboard

Volume subpath silently fails

Open pikeas opened this issue 1 year ago • 2 comments

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.

pikeas avatar Sep 13 '24 22:09 pikeas

https://github.com/docker/cli/pull/5833 seems related.

It would be great to have subpath support in Swarm!

pikeas avatar Mar 29 '25 20:03 pikeas

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.

meyayl avatar Nov 23 '25 16:11 meyayl