# Propogating rclone mounts to Docker containers without transport endpoint going stale

**URL:** <https://forum.rclone.org/t/propogating-rclone-mounts-to-docker-containers-without-transport-endpoint-going-stale/48112>\
**Category:** Howto Guides\
**Created:** [October 7, 2024, 5:34pm UTC](https://forum.rclone.org/t/propogating-rclone-mounts-to-docker-containers-without-transport-endpoint-going-stale/48112 "2024-10-07T17:34:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliasbenb](https://forum.rclone.org/user_avatar/forum.rclone.org/eliasbenb/32/18070_2.png) [@eliasbenb](https://forum.rclone.org/u/eliasbenb)\
**Post date:** [October 7, 2024, 5:34pm UTC](https://forum.rclone.org/t/propogating-rclone-mounts-to-docker-containers-without-transport-endpoint-going-stale/48112/1 "2024-10-07T17:34:42Z")

</div>

I'm writing this guide because after over a year of trying to figure out how to get around this issue, I finally found a solution (and it's just one line). Jump to the end of this thread if you just want the code without the context.

_The issue:_

If you've ever binded an rclone mount as a volume for a Docker container then you must be familiar with this problem. If an rclone mount that is binded as a volume to a Docker container is ever restarted, the mount (transport endpoint) becomes stale and the Docker container will no longer be able to see the mount. To get around this you would have to restart the container every time the rclone mount is restarted.

_The solution:_

You could just make sure the dependent containers only start after the rclone mount is connected (and in fact this is what I did for a very long time using Docker health checks), but this is very slow and creates other complications.

A better solution I recently discovered is to change the Docker volume's bind propagation method to `rshared`. This flag recursively shares any child mount points at the bind volume's path with the container. For example, let's say your rclone mount is at the path `/mnt/data` on the host. Your bind volume configuration in a `compose.yaml` will then be:

```yaml
volumes:
  - /mnt:/mnt:rshared

```

Notice that I did not bind `/mnt/data` you MUST bind the parent directory, otherwise it will not propagate correctly. With that, rclone mounts will propagate correctly even after a mount is restarted.

I've never seen this solution posted anywhere which is why I'm sharing, hopefully this saves someone from the frustration I went through 🙂

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [October 8, 2024, 3:36pm UTC](https://forum.rclone.org/t/propogating-rclone-mounts-to-docker-containers-without-transport-endpoint-going-stale/48112/2 "2024-10-08T15:36:18Z")

</div>

Do you think we should put this on the docs?

I think there has been discussion of rshared either here or on GitHub before.

---

<div class="post-metadata">

**Author:** ![eliasbenb](https://forum.rclone.org/user_avatar/forum.rclone.org/eliasbenb/32/18070_2.png) [@eliasbenb](https://forum.rclone.org/u/eliasbenb)\
**Post date:** [October 12, 2024, 6:19am UTC](https://forum.rclone.org/t/propogating-rclone-mounts-to-docker-containers-without-transport-endpoint-going-stale/48112/3 "2024-10-12T06:19:16Z")

</div>

Hey, sorry about the late reply. I definitely think adding this to the docs would be helpful. I've been sharing this tip with a bunch of people over the last few days and they've all been happy to get it working the way I described.

One thing I'll say is that if you add this to the docs, maybe use a different example to the one I used. Mapping `/mnt:/mnt` would be bad practice and a security issue. Someone less tech savvy might not realize that.

---

<div class="post-metadata">

**Author:** ![eliasbenb](https://forum.rclone.org/user_avatar/forum.rclone.org/eliasbenb/32/18070_2.png) [@eliasbenb](https://forum.rclone.org/u/eliasbenb)\
**Post date:** [November 4, 2024, 6:37pm UTC](https://forum.rclone.org/t/propogating-rclone-mounts-to-docker-containers-without-transport-endpoint-going-stale/48112/4 "2024-11-04T18:37:46Z")

</div>

@ncw I'm not sure if you still plan to add this to the docs but I found some more info that might be useful if you do.

If you look back at my original post, I mentioned that you need to mount the parent directory of the target folder. This can actually be avoided. I found that the `rslave` bind propagation has the same benefits of `rshared` but without needing to pass the entire parent directory (probably because rslave propagates mounts in one direction unlike rshared which is bidirectional).

This is obviously better because we have more granularity with restricting file access to the containers. Like I mentioned in my original post, binding the parent directory could be a security issue.

Here's a more full example using the `rslave` method instead `rshared`.

```yaml
services:
  rclone:
    image: rclone/rclone:latest
    command: mount xxx:/ /data --allow-other
    volumes:
      - /mnt/data:/data:rshared

  some_service_that_needs_the_rclone_mount:
    image: some_image
    volumes:
      - /mnt/data:/data:rslave

```

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [November 4, 2024, 7:26pm UTC](https://forum.rclone.org/t/propogating-rclone-mounts-to-docker-containers-without-transport-endpoint-going-stale/48112/5 "2024-11-04T19:26:54Z")

</div>

> [@eliasbenb](#):
>
> full example using the `rslave` method instead `rshared`.  
> /mnt/data:/data:rshared

your example still uses `rshared` ??

---

<div class="post-metadata">

**Author:** ![eliasbenb](https://forum.rclone.org/user_avatar/forum.rclone.org/eliasbenb/32/18070_2.png) [@eliasbenb](https://forum.rclone.org/u/eliasbenb)\
**Post date:** [November 4, 2024, 7:56pm UTC](https://forum.rclone.org/t/propogating-rclone-mounts-to-docker-containers-without-transport-endpoint-going-stale/48112/6 "2024-11-04T19:56:29Z")

</div>

> [@asdffdsa](#):
>
> your example still uses `rshared` ??

Yes, but only on the rclone container. That's intended.

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [November 4, 2024, 8:02pm UTC](https://forum.rclone.org/t/propogating-rclone-mounts-to-docker-containers-without-transport-endpoint-going-stale/48112/7 "2024-11-04T20:02:09Z")

</div>

> [@eliasbenb](#):
>
> Yes, but only on the rclone container. That's intended.

ok, good.  
you are welcome to edit the documents yourself, click the pencil icon at  
[https://github.com/rclone/rclone/blob/master/docs/content/install.md](https://github.com/rclone/rclone/blob/master/docs/content/install.md)

have you seen these pages?  
[https://rclone.org/docker/](https://rclone.org/docker/)  
[https://rclone.org/commands/rclone\_serve\_docker/](https://rclone.org/commands/rclone_serve_docker/)

---

<div class="post-metadata">

**Author:** ![eliasbenb](https://forum.rclone.org/user_avatar/forum.rclone.org/eliasbenb/32/18070_2.png) [@eliasbenb](https://forum.rclone.org/u/eliasbenb)\
**Post date:** [November 11, 2024, 12:30am UTC](https://forum.rclone.org/t/propogating-rclone-mounts-to-docker-containers-without-transport-endpoint-going-stale/48112/8 "2024-11-11T00:30:10Z")

</div>

> [@asdffdsa](#):
>
> you are welcome to edit the documents yourself, click the pencil icon at  
> [https://github.com/rclone/rclone/blob/master/docs/content/install.md](https://github.com/rclone/rclone/blob/master/docs/content/install.md)

Opened a PR for this at [docs: Docker mount docs with compose example by eliasbenb · Pull Request #8171 · rclone/rclone · GitHub](https://github.com/rclone/rclone/pull/8171)
