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?

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.