Need allow docker to create folder if it no existed in source

The classic solution would be to actualy use a named volume baked by nfsv4, pointing to the mnesia folder of the remote share. Then use the named volume (instead of bind-mounts) and map it into /var/lib/rabbitmq/mnesia.

Then set use the environment variable RABBITMQ_MNESIA_DIR=/var/lib/rabbitmq/mnesia/{{.Service.Name}}/{{.Task.Slot}}

Though, I would strongly advise to NOT use the {{.Task.ID}} as it is prone to change. See here for the template placeholds and example values.

N.B.: do not use the template placeholders in named volume declarations, as once a volume is created, its configuration is immutable. So whatever the current value for {{.Service.Name}}/{{.Task.Slot}}/{{.Task.ID}} will be when the named volume is created, it is carved into stone one that node (until you manualy delete it and let it re-create). This is an undesired behavior! Been there, done that, didn’t like the outcome :wink: