docker compose fails to mount sub-directories of named volumes #47687
Labels
kind/bug
Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.
status/0-triage
Description
A few days ago a new docker version (v26) released a new feature to allow mounting sub-directories of named volumes. volumes: Implement subpath mount was implemented.
It works when using the
docker run
command.However, when using the long syntax on docker compose files, it seems to mount everything on the root path and not on the sub-directory specified in the
volume options
section. Thesubpath
seems to be ignoredReproduce
I have two servers (client = 10.0.0.3 and manager = 10.0.0.2) in the docker swarm.
On the client 10.0.0.3 create and share the directory
/var/web
. Create also an empty sub directory/var/web/portainer_data
thereGo to swarm manager (10.0.0.2) and create the shared named volume:
Run the service on the server manager (10.0.0.2)
docker compose -f portainer.yml up -d
Confirm in the client that all the portainer files are created under
/var/web
(WRONG = BUG)Confirm also in the client that the sub directory
/var/web/portainer_data
is empty (WRONG = BUG)Remove the container on the manager and the wrong files created on the client
Now, run the same command above using
docker run
:/var/web/portainer_data
is NOT empty.Expected behavior
After running the command
docker compose -f portainer.yml up -d
the following behavior is expected:/var/web
/var/web/portainer_data
is NOT emptydocker version
Client: Docker Engine - Community Version: 26.0.0 API version: 1.45 Go version: go1.21.8 Git commit: 2ae903e Built: Wed Mar 20 15:17:48 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 26.0.0 API version: 1.45 (minimum version 1.24) Go version: go1.21.8 Git commit: 8b79278 Built: Wed Mar 20 15:17:48 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.28 GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb runc: Version: 1.1.12 GitCommit: v1.1.12-0-g51d5e94 docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info
Additional Info
Just ignore the word "swarm" for test / reproduction purposes. The files above do not need a swarm to be tested (I think).
However, at the end I will use the solution for a swarm cluster and need to use compose files to deploy many services that point to different sub directories on the shared named volume.
The text was updated successfully, but these errors were encountered: