Volumes when using git repository
Before you start please confirm the following.
- Yes, I've searched similar issues on GitHub.
- Yes, I've checked whether this issue is covered in the Portainer documentation.
Problem Description
I have just started using a git repository for my compose files and have had some issues getting the volumes to work.
Let's say my stack is called test_stack and looks like this: services: stack1: image: k8s.gcr.io/pause:3.9 container_name: stack1 restart: unless-stopped volumes: - test_volume:/test
volumes: test_volume: driver: local driver_opts: type: none o: bind device: /mnt/NAS/test_volume
The stack is fails to deploy because it is looking for a volume called test_volume, but the stack is creating the volume and calling is stack1_test_volume. This does not happen with the same compose files when using the web editor and it correctly appends the stack name to the volume.
As a work around, I add name: test_volume to the volume and the stack will then deploy successfully as it no longer appends the name to the volume. volumes: test_volume: name: test_volume driver: local driver_opts: type: none o: bind device: /mnt/NAS/test_volume
This is the actual error message and I have substituted the actual volume information with the test_volume from above: failed to deploy a stack: compose up operation failed: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/stack1_test_volume/_data': failed to mount local volume: mount /data/compose/10/61e981911b575157aa4c9b71afb5f28b0809fd37/test_volume:/var/lib/docker/volumes/test_vollume/_data, flags: 0x1000: no such file or directory
Expected Behavior
When using a volume in a compose file from a git repository, it should not be necessary to use the name: option when creating a volume. The correct volume name should be detected like it is when using the web editor.
Actual Behavior
The volume is created and appends the stack name as a prefix, while the stack attempts to use the volume name without the prefix which causes the deployment to fail.
Steps to Reproduce
Create a compose files for a stack similar to this in git repository and try to deploy. The deployment should fail. Add name: test_volume to the volume and it should succeed: services: stack1: image: k8s.gcr.io/pause:3.9 container_name: stack1 restart: unless-stopped volumes: - test_volume:/test
volumes: test_volume: driver: local driver_opts: type: none o: bind device: /mnt/NAS/test_volume
Portainer logs or screenshots
failed to deploy a stack: compose up operation failed: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/stack1_test_volume/_data': failed to mount local volume: mount /data/compose/10/61e981911b575157aa4c9b71afb5f28b0809fd37/test_volume:/var/lib/docker/volumes/test_vollume/_data, flags: 0x1000: no such file or directory
Portainer version
2.41.0
Portainer Edition
Business Edition (BE/EE) with 5NF / 3NF license
Platform and Version
Docker 29.4.3
OS and Architecture
Ubuntu 24.04
Browser
Safari on iPadOS 26.4
What command did you use to deploy Portainer?
name: portainer-be
services:
portainer-be:
image: portainer/portainer-ee:sts
container_name: portainer-be
hostname: portainer-be
restart: unless-stopped
ports:
- "9445:9443"
- "8021:8000"
networks:
- internal
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime # Tried this because the timestamps are wrong when viewing logs for containers
- portainer-be_data:/data
networks:
internal:
external: true
volumes:
portainer-be_data:
driver: local
driver_opts:
type: none
o: bind
device: /mnt/NAS/portainer/dataAdditional Information
I had already typed all the stuff in the first box before I saw all the other boxes and I'm too lazy to remove it all. lol
Source: portainer/portainer