How to persist data in docker container

Jibin Liu on September 15, 2018

TL;DR Containers are supposed to be light-weighted. Adding unnecessary data will make it heavy to create and run. Docker provides several ways t... [Read Full]
markdown guide
 

Hi, thanks for your article

Can we store multiple containers data in one volume.

Container1
-- Folder
   -- File1.json
   -- File2.json

Container2
-- Folder
   -- File1.json
   -- File2.json

This is what we currently have, it's essentailly that files gets written in each containers by the end user of the app, and there is this one container with our backend that has to scan all the files and show them in file manager as nested structure. So we want to make these containers independent of user generated data and scanning the shared volume would be much more easier for us.

Can we do it like this

Shared Volume
-- Container1Data
   -- Folder
      -- File1.json
      -- File2.json
-- Container2Data
   -- Folder
      -- File1.json
      -- File2.json
 

Hi Liu. Thanks for your explanation, helped me lot as I'm pretty new in Docker. Just wondering if the volume is persistent in case of switching computer off/on?

 

Hello,

Yes, the data is persisted until you explicitly delete the explicitly-created volume.

code of conduct - report abuse