Reputation: 151
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)
Upvotes: 6
Views: 16734
Reputation: 1324178
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.
Upvotes: 4
Reputation: 3627
Its not clear from your text if you have removed the volume with the container - then its gone - otherwise and by default you can find "raw" docker volumes here: /var/lib/docker/volumes/
. Check the docs for docker rm -v
.
Normally you would create a volume by docker run ... -v hostpath:containerpath ...
and then you have your data always at hostpath
available, no matter if you remove your container or not.
Upvotes: 1