dockur / windows

Windows inside a Docker container.
MIT License
15.99k stars 1.33k forks source link

[Feature]: Implement snapshot support #485

Open uhidontkno opened 2 months ago

uhidontkno commented 2 months ago

Is there an existing feature request for this?

Is your proposal related to a problem?

Instead of waiting up to 15 minutes for Windows to install, I propose that a snapshot feature should be implemented so that there should be a way to install windows once, make a snapshot for it, then be able to load it anytime for instant Windows installations.

Describe the solution you'd like.

One solution could be to have a way to save the entire VM's disk to somewhere else using docker cp for example, then feeding that file into the Windows Docker Container, or simply implement QEMU snapshots support

Describe alternatives you've considered.

I haven't tried anything yet.

Additional context

No response

lucaspdude commented 2 months ago

Interested in this also.

At work we use some old VB6 configured machine and it would be really nice if we could make snapshots since most of the configuration is manual for this environment.

kroese commented 2 months ago

Inside the /storage volume there is a file called data.img that contains the whole harddisk.

So the only thing you need to do for instant installations is to provide an existing /storage volume, which can be binded to a local folder like this:

volumes:
  - /example/folder:/storage

So for backing up or restoring machines, all you need to do is make a copy of /example/folder. And if you have multiple folders, you can easily switch between them by changing that line in your compose file.

I have no plans to implement QEMU snapshots, but the above method should provide pretty similar functionality. The only difference is that you cannot make a copy of /storage while the machine is powered on and that it uses a bit more diskspace because nothing is layered like with real snapshots.

baiomys commented 2 months ago

ZFS volume can be passed to docker instead of /storage via /dev/zvol/mypool/myvol:/disk1 It has native support for compression, snapshots, encryption, thin provisioning, etc. So it is worth spending couple of days reading ZFS for dummies. =)

TeroKeso commented 1 month ago

ZFS passthrough would be a good addition to readme.md. Like @baiomys did say just link them to some instructions page like https://blog.victormendonca.com/2020/11/03/zfs-for-dummies/ if they need more info

kroese commented 1 month ago

@TeroKeso There is already a section about disk pass-through in the readme. It doesnt recommend a specific filesystem, but ZFS is not the only filesystem that can do snapshots, there is also BTRFS for example, which is a lot easier to setup for newbies propably.

In fact: its not even needed to use disk pass-through at all to use snapshots, you can also snapshot the partition that contains the/storage folder instead.

So I will not recommend a specific filesystem for snapshots in the readme. The recommended way to backup the container is to just make a periodic copy of the /storage folder. And how you make that copy (manually or via snapshots) is up to the user.

TeroKeso commented 1 month ago

You are absolutely right about the difficulty level. I just understand what I'm doing and that's why I suggested writing the instructions. I'm not experienced enough to write instructions and see all possibilities.

Zvol or similar helps with snapshot+backup when /storage is just one big file (HDD).

Thank you for taking the time to reply and I'm sorry that my question got a bit out of the title/topic

kroese commented 1 month ago

@TeroKeso Your suggestion was not off-topic at all.

But personally I have never used ZFS (because it looked so difficult), so I'm just a bit hesitant to recommend it to other people, because its better to only recommend things you have personal experience with.

Also because there are other options, like BTRFS for snapshots, I do not want to steer people in a certain direction, when I do not know which of the options is the best or easiest.

baiomys commented 1 month ago

ZFS makes you think completely different, it extends old plain storage paradigm in new dimension. That's why learning curve is kind of steep.