Docker Community Forums

Share and learn in the Docker community.

Detaching/removing a bind mount from a running container


I am investigating the prospect of detaching bind mounts from running Docker containers. So far it seems like this won’t work out of the box, so I’m wondering whether anyone can point me to a good guide or to the correct documentation where I can understand the gritty details and nuances of docker bind mounts and volumes. I don’t mind issuing a pull request to the appropriate repo with new functionality if needed.

My use-case is fairly straightforward. It takes too long to spin up new containers at scale with the performance constraints I need to work with and, as such, one option I’m exploring is creating a read-only bind mount for a specific directory on the host, using it as needed, then promptly removing the bind mount. When a new request comes in from the queue I would repeat the process by once again creating a new bind mount – perhaps on a different directory from the host this time. I can only have one directory mounted at a time for security reasons.

Obviously the aforementioned approach requires removing a bind mount from a running container, so that’s the root of my question. Thanks in advance to anyone who can shed some light on this!