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?

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.

×
1 answer

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.

  • Thank you! This is mostly for user generated content like image uploads or generated HTML templates or CSS files that this app produces.

    I appreciate the different approaches and will investigate the 3rd option you mentioned.

    • Object storage is the perfect solution for image uploads. This way you never have to worry about space, partitions, directories, and you can just continue to upload as many images as you like, so Spaces would be the best approach.

Submit an Answer