wetopi / docker-volume-rbd

Docker Engine managed plugin to manage RBD volumes.
MIT License
69 stars 18 forks source link

Cannot mount the same volume in multiple containers running on the same host #16

Closed laszlojau closed 3 years ago

laszlojau commented 4 years ago

Environment: OS: CentOS 7 Ceph 14.2.9 nautilus (stable) Docker version: 19.03.9 Using wetopi/rbd:3.0.0

I have been trying to use the same volume with multiple containers on the same host, but I have been running into issues.

Expected result Multiple containers are able to share the same volume, just like with the local driver.

Issue When the volume is already in use and I try to start a new container using the plugin, it runs rbd map. This causes the new container to fail to start and terminate with exit status 32 if another running container is already using this volume. If I stop the original container, I can start up the new container and it doesn't try to run rbd map again.

Steps to reproduce:

  1. Create volume

    $ docker volume create -d wetopi/rbd -o pool=rbd -o size=200 ceph_test_volume
  2. Start a container in the background that mounts the volume and keeps running:

    $ docker run -d -v ceph_test_volume:/data --volume-driver=wetopi/rbd busybox sleep inifinity
  3. Check /dev/rbd/rbd on the host where the container is running:

    $ ls -l /dev/rbd/rbd/
    lrwxrwxrwx. 1 root root 10 May 25 14:30 ceph_test_volume -> ../../rbd0
  4. Try to start another container, using the same volume:

    $ docker run -it -v ceph_test_volume:/data --volume-driver=wetopi/rbd busybox sh
    docker: Error response from daemon: error while mounting volume '/var/lib/docker/plugins/537232edf06.../propagated-mount/ceph_test_volume':
    VolumeDriver.Mount: volume-rbd Name=ceph_test_volume Request=Mount Message= unable to mount: exit status 32.
  5. Check /dev/rbd/rbd on the host where the container is running:

    $ ls -l /dev/rbd/rbd/
    lrwxrwxrwx. 1 root root 10 May 25 14:32 ceph_test_volume -> ../../rbd1
Cussy23 commented 3 years ago

You need to disable mmp (Multiple Mount Protection). Add -o mkfsOptions="-O ^mmp" when creating a volume. Example: docker volume create -d wetopi/rbd -o mkfsOptions="-O ^mmp" rbd_volume

When you add "^" in front of mmp it disables Multiple Mount Protection option.

Create Volume

laszlojau commented 3 years ago

Thank you!