Skip to content

don't work volume option subpath in docker swarm mode #5826

@bobro99

Description

@bobro99

Hi all!
I use docker swarm to access the directory inside the created volume (volume is test_volume, direcotry is test). Docker swarm consists of one machine, on which the volume is located. I use the same compose-file. docker-compose up mounts the required volume folder inside the container
docker stack deploy --prune --compose-file docker-compose.yml test_2 This command only mounts the volume itself, but not the folder inside it, as I would expect from the command docker run --mount 'type=volume,src=test_volume,dst=/srv,volume-subpath=test' -it --entrypoint sh alpine:3.18.5
My docker-compose.yml

version: '3.7'
volumes:
  test_volume:
    external: true

services:
  alpine-test:
    image: alpine:3.18.5
    deploy:
      placement:
        constraints:
          - node.hostname == mynodename
      restart_policy:
        condition: on-failure
    volumes:
      - type: volume
        source: test_volume
        target: /srv
        # volume options
        volume:
          subpath: test
    command: "tail -f /dev/null"

docker info:

# docker system info
Client: Docker Engine - Community
 Version:    26.1.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.14.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.27.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 6
  Running: 1
  Paused: 0
  Stopped: 5
 Images: 1
 Server Version: 26.1.1
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: active
  NodeID: lhxizmfg9fx9qnk0v3h07d2o3
  Is Manager: true
  ClusterID: oma6m5qjj3golwzivz86smz79
  Managers: 1
  Nodes: 1
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: 172.30.3.192
  Manager Addresses:
   172.30.3.192:2377
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e377cd56a71523140ca6ae87e30244719194a521
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 3.10.0-1160.25.1.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 11.58GiB
 Name: mynodename
 ID: b822c40a-2837-40a0-b3b1-507850527b12
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 54
  Goroutines: 179
  System Time: 2024-05-07T22:12:55.242252032+03:00
  EventsListeners: 1
 Username: dubzap
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

[DEPRECATION NOTICE]: API is accessible on http://0.0.0.0:2375 without encryption.
         Access to the remote API is equivalent to root access on the host. Refer
         to the 'Docker daemon attack surface' section in the documentation for
         more information: https://docs.docker.com/go/attack-surface/
In future versions this will be a hard failure preventing the daemon from starting! Learn more at: https://docs.docker.com/go/api-security/
[DEPRECATION NOTICE]: API is accessible on http://0.0.0.0:2376 without encryption.
         Access to the remote API is equivalent to root access on the host. Refer
         to the 'Docker daemon attack surface' section in the documentation for
         more information: https://docs.docker.com/go/attack-surface/
In future versions this will be a hard failure preventing the daemon from starting! Learn more at: https://docs.docker.com/go/api-security/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions