Question

Persistent storage across multiple docker containers?

Considering a move to DO for a project I’m working on, and was wondering what the recommended way is to share storage between multiple docker containers…

From what I’ve read, Block Storage can only be mounted on one droplet at a time. Would it be wise to mount to a droplet, then share that via NFS? Has anyone done this without major negative performance consequences?

Is there another way people might recommend sharing storage space across docker app volumes?

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

There are three approaches to this. One is as you mentioned to attach block storage to one container and then export it via NFS. However, this will require configuration on your part and management as well as ensuring that the NFS connection doesn’t break.

Alternatively, you can look at what your storage needs are and break them out by usage. For databases you would be better off using a separate droplet to manage your DB or our managed DB service.

And for static assets you can use Spaces Object Storage. This allows the containers to be more stateless and easier to replace, as well as ensuring consistency of data because distinct systems are handling your storage needs. It also makes everything more scalable immediately as you are using a pre-defined service for the specific function it was intended for.