How to create a gradle dependency cache shared by multiple docker containers?

I want to implement gradle dependency cache that will be shared by multiple docker containers. I went through the gradle docs. It talks about building readonly cache. It stated that there are locks being used and multiple writes to the same cache could cause issues.

We still need to write new dependencies to the cache. Can someone please suggest what is the best route to go?

The read-only cache will be additional to the read-write cache.
Writes will happen to the container instance exclusive read-write cache.
If you want to add something to the read-only cache, do it dedicated like when initially creating it.