Search code examples
dockerbackupcontainersvolumerestore

Docker restore volume of removed container?


At the moment I am trying to understand some scenarios concerning data persistence.

The Data Volume Container Pattern sounds great, and there are ways to backup the attached volumes. But what if I have no current backup the DataVolumeContainer gets removed (rather than only stopped)?

From what I understand the volume is physically still present on my host system, but I can't attach it to a new container (since there's no referencing container left).

Is there a possibility to restore that volume (e.g. mount it to a new container) by referencing its volume file or the volume name? (assuming that I named the volume)


Solution

  • but I can't attach it to a new container (since there's no referencing container left).
    Is there a possibility to restore that volume (e.g. mount it to a new container) by referencing its volume file or the volume name (assuming that I named the volume)?

    Yes there is: if you can find your old volume path, you can, as I mentioned in "Docker mount dangling volume", restore its content in a new (and empty) data volume container by replacing its mounting path content with the one found in the old path.

    I prefer saving that path whenever I create a new data volume container.