Merging a volume on a Windows Host to a Windows Container?
May 24, 2022 2:52 PM   Subscribe

I have a legacy .NET web application on a Windows container with a Windows 11 host. To make updates I will need to build and move a few artifacts to a non-empty container folder from the base image (wwwroot/inetpub). The build process does not contain all the items in the directory so if I mount the bin folder of the container '-v msbuild-output/bin:wwwroot/inetpub/bin' the build output will overwrite what's in the bin folder, e.g., deleting the 400 or so assemblies in the container and replacing it with the dozen from the build. I need to ideally add/overwrite as if I was building on a local file system without doing a git clean. This is for development only, so I can be sloppy but I'm looking for any solution to get this going, bonus points if it doesn't involve anything extra on the Windows host (so anyone can pull down the container and start developing). I've looked into Windows Filesystem Proxy, I'm not quite understanding if it can help. There has to be an elegant solution. Help?

Sorry if this is complex but I figure someone has done this before. What I'm looking for at the bare minimum is on build to overwrite files or add files, but not delete on the container. If I can see and edit files on the running container that's a bonus (knowing that when I turn it off and recreate the container the changes will disappear). Ideally the the build process would recreate the application from scratch but that's not possible, the /wwwroot/bin folder on the container is 500mb alone. The other folders in wwwroot/* total something like 2GB.

If it matters the only things that I normally need to update would be the wwwroot/bin, wwwroot/views, wwwroot/styles if that matters. I have free reign to install or update anything on the container image. Multiple bin folders? The only "gotcha" is that my build on the server outputs a few assemblies that overwrite the same named assembly. So my build might generate "LegacyAssembly.dll" that needs to overwrite the "LegacyAssembly.dll" in the running container. The logic is the output of the build is the truth and can always overwrite and add what's in the container.
posted by geoff. to Computers & Internet (2 answers total)
 
Best answer: Can you build as usual, and then have a post-build step to call docker cp to copy the built files into the container at the appropriate paths?
posted by inkyz at 8:59 PM on May 24, 2022


Response by poster: Ah! Yes so I forgot, you have to stop/start the container in Hyper-V to use `cp` or you get this:

Error response from daemon: filesystem operations against a running Hyper-V container are not supported

But if you run it in process isolation it works! I'm pretty sure this is a recent improvement as this did not work a couple years ago. Windows Docker world is very confusing as Microsoft is promoting it heavily and doesn't do a great job of outlining the caveats. It was a lot worse a couple years ago when I was new to Docker and the documentation was a complete mess, it is still not great. Now that I understand what I want to do and how it works in Linux it is a lot easier to at least know what needs to be done.

I would not recommend Docker for legacy projects or for Windows unless necessary. WSL2 and running Linux containers on Windows is great and I've had no issues.
posted by geoff. at 11:21 PM on May 24, 2022


« Older What's cool in bluegrass music these days?   |   is there a name for this traffic scenario? Newer »
This thread is closed to new comments.