Docker Community Forums

Share and learn in the Docker community.

Data volumes - surviving engine upgrades


(Asifarran) #1

I am new to Docker and have just got a taste of how volatile things are when I had to downgrade Docker for Windows to a previous version to get port forwarding to localhost working again (as per this issue).

I intend to run postgresql in a container and use an data volume to persist the db’s data independently from the container.

Having had to update (in this case backwards) the engine I notices the Moby VM gets destroyed and re-created which effectively means everything in it (including the data volumes) evaporates.

That seems impossibly scary!

Am I missing something here? How does one set up a persistent data volume that lives across Docker engine updates?

Thanks in advance


(Sam) #2

the persistent data volume must be on the host media, and mounted into the containers for use.
that way, when the containers stop, the data doesn’t go away


(Asifarran) #3

Please note that I am not asking about how to persist data when containers stop/start but how to do so without worrying about updates to Docker for Windows itself causes the volumes to be deleted (as part of re-creating the MobyLinux VM)


(Sam) #4

sorry, i don’t understand the distinction…

if the containers might stop for any reason, then the persistent data volumes CANNOT be inside containers.


(Asifarran) #5

Yes, they live inside the VHDX disk that contains the MobyLinuxVM which is created by Docker for Windows as part of the installation process.

So, you can start, stop and re-create containers at will and your data volumes are safe.

BUT, if you now want to upgrade Docker for Windows itself to a new version, that VHDX gets thrown away and replaced by a new one and with it goes all your data.


(Sam) #6

put the data volumes on C: (or some other WINDOWS HOST volume) not IN the VHDX


(Asifarran) #7

I wish, but for some scenarios (I for example want to run postgresql in a container) you can’t use an NTFS volume.


(Sam) #8

well, THAT is a different problem… I can’t see how it would know… if you use -v or --mount,type=bind

i see the bug… and the workaround, ‘backup regularly’!..


(Asifarran) #9

It wouldn’t care when you install but would fail when syncing to disk at runtime. It expects ext.

I realize that the context for my question is outside the scope of this topic but still maybe someone can point to an alternative solution. for example, is it possible to setup and connect a second virtual disk (i.e other than the MobyLinuxVM one) and mount volumes to containers from it ?


(Sam) #10

you would have to create some virtual windows disk, and THAT seems to be a problem.

NFS also reported to fail…

there are VDISK drivers for windows, but those are memory backed.