Search code examples
dockerdocker-volumefuse

docker volume over fuse : Transport endpoint is not connected


So I have this remote folder /mnt/shared mounted with fuse. It is mostly available, except there shall be some disconnections from time to time.

The actual mounted folder /mnt/shared becomes available again when the re-connection happens.

The issue is that I put this folder into a docker volume to make it available to my app: /shared. When I start the container, the volume is available.

But if a disconnection happens in between, while the /mnt/shared repo on the host machine is available, the /shared folder is not accessible from the container, and I get:

user@machine:~$ docker exec -it e313ec554814 bash
root@e313ec554814:/app# ls /shared 
ls: cannot access '/shared': Transport endpoint is not connected

In order to get it to work again, the only solution I found is to docker restart e313ec554814, which brings downtime to my app, hence is not an acceptable solution.

So my questions are:

  1. Is this somehow a docker "bug" not to reconnect to the mounted folder when it is available again?

  2. Can I execute this task manually, without having to restart the whole container?

Thanks


Solution

  • I would try the following solution.

    If you mount the volume to your docker like so:

    docker run -v /mnt/shared:/shared my-image
    

    I would create an intermediate directory /mnt/base/shared and mount it to docker like so:

    docker run -v /mnt/base/shared:/base/shared my-image
    

    and I will also adjust my code to refer to the new path or creating a link from /base/shared to /shared inside the container

    Explanation:

    The problem is that the mounted directory /mnt/shared is probably deleted on host machine, when there is a disconnection and a new directory is created after connection is back. But, the container started running with directory mapping for the old directory which was deleted. By creating an intermediate directory and mapping to it instead you avoid this mapping issue.