Swarm Service bind mounts not working unless manually created
To Reproduce
- Create a cluster with at least 1 worker node
- Create any application
- Force placement on worker node
- Create bind mount to an absolute path
- Deploy application
Current vs. Expected behavior
Current behaviour: The service endlessly tries to start up, never succeeds. The following error message is displayed:
invalid mount config for type "bind": bind source path does not exist: /<parent-dir>/<mount-path>
Even when <parent-dir> has chmod 777, the mount is not created.
Expected behaviour: The directory tree up until the mount directory is created on either saving the bind mount config, or on deployment. Might even benefit from notifying the user with a 'directory does not exist' dialog, with options to create the directory.
Provide environment information
OS: Ubuntu 22.04
VPS Provider: DigitalOcean
Which area(s) are affected? (Select all that apply)
Application, Docker Compose, Docker
Are you deploying the applications where Dokploy is installed or on a remote server?
Both
Additional context
Just as some extra info: I use a glusterfs setup, sharing files on the same path over all of my swarms nodes in disperse mode. Bind mount are thus shared, and can be statically defined. This works great by the way, but the system won't create the mounts for me.
Will you send a PR to fix it?
Yes
How did you configured swarm its not working I tried with shared and dedicated vps first time showed docker demeon timeout when try second time it shows this already joined a swarm and not showing in the cluster tab
Using vultr cloude
Another scenario with the same problematic:
Steps to reproduce:
- Dokploy server (node dokploy0)
- Added another two nodes to the cluster (nodes dokploy1, dokploy2)
- Create application on Dokploy server
- Add file mount to application. File is available in dokploy server at
/etc/dokploy/applications/APP_NAME/files/FILE_NAME - Replicas fail to start on nodes dokploy1 or dokploy2 because the file doesn't exists there. The error is:
s0rqz9y0sull28uwn43zmy7yq _ test-gvrapp-dt5hlv.3 registry.example.com/group/web/develop:latest dokploy1 Shutdown Rejected 11 minutes ago "invalid mount config for type "bind": bind source path does not exist: /etc/dokploy/applications/APP_NAME/files/FILE_NAME"
I've had the same situation.
If I'm not mistaken, the bind mount directory must exist, dokploy and docker swarm will not create it for you.
I think this is not a bug or anything, it is expected if you try to deploy an application manually using docker swarm, it will still throw a warning since that directory does not exist in the worker node which makes sense.
I think I will add a warning in the UI to warn that if you use the cluster features that the directories will not be created automatically nor will they be shared, for that you have to make use of distributed storages and integrating this to dokploy would be too much work for now.