Closed wglanzer closed 5 years ago
Hi @wglanzer, that is actually really easy to accomplish.
First you have to manually create the volume on one of your swarm manager nodes:
$ docker volume create --driver lizardfs DOC_DATA
That will create the volume without the stack name prefix. After it is created you can mount it into your swarm stack as an external volume by doing something like this in your stack YAML:
services:
my_service:
volumes:
DOC_DATA:/doc_data/or_other/mountpoint
volumes:
DOC_DATA:
external: true
The external: true
flag in the volume declaration tell swarm not to scope the volume name and to look for an already existing volume outside of the stack. That is why you have to create it manually. If you do this in both of the stacks that need access to the volumes, it should work how you are needing it to.
Hope this helps! :smiley:
Thank you, this helped me out 😃 Got a second question - but I'll open another issue.
I got the following problem: It seems, that docker swarm / the lizardfs plugin generates a volume name, with the stack name as a prefix. With this behavior in general, how can I "share" a volume between two containers? I think the path inside the lizardfs mount is the same as the volume name - so that they wont share data.
Example with two swarm stacks:
Stack: Documentation Volume: DOC_DATA
Stack: CI Volume: DOC_DATA
Both of them should point to the same amount of data, because my ci-server writes a bit of autogenerated code to the documentation part.
Am I able to achieve this behavior somehow?