For the last 3 weeks I have been intensively learning docker and running it locally. It is really great and I love the simple clear commands, and the fact that it just works and diagnostics and errors are generally clear.
So I decided to see If I could containerize a WinForms application written in C#.
I used the Microsoft image: mcr.microsoft.com/windows/servercore:2004 and created a container called petewin. This image seems to have all the stuff needed and should be like my Windows 10 host.
I found out that I couldn’t switch to Windows containers because my development laptop was running Windows 10 Home (I never knew, and it is core i7 8th gen system…). I paid MS the money and successfully upgraded to Windows 10 Pro. Now I was able to switch to Windows Containers in Docker without problem.
I decided to try running something in the container and opted for the Dir command of cmd.exe
I used: docker exec petewin cmd.exe | dir .
A directory display appeared on my screen and I was pretty pleased.
Tried again with Notepad…
docker exec petewin cmd.exe | Notepad
A notepad window appeared and I was overjoyed.
Then I realized that the piped commands were actually running on my host (Local machine) and not in the container. It made sense, but I was crushed
I thought I might have better luck with the WinForms stuff so I copied it to the container.
I tried to execute the main form: docker exec \AUCD0014.exe (expecting a small form window to appear but there was nothing.) I used Ctrl/c to stop it and get the PS prompt back.
It was then that I searched and found this thread, where, in 2016, Michael said it can’t be done. There is/was no GUI support.
And yet the -i parameter indicates “interactive” and surely the MS server image must have the libraries needed to make a WinForm. (They are just a string of C# commands to underlying libraries, after all…)
I found many conflicting comments on the web saying it can and it can’t be done, but if it really can’t be done, here in 2020, then I have been wasting my time with Docker.
I know I could use a VM, but that is not what I want to do and it wouldn’t be viable for the number of applications I am thinking about.
Can I please have a definitive statement regarding the following:
-
Can I interact with a WinForm running in a container based on the MS server image? (what commands/parameters have I missed and need?)
-
If it really is not possible, is there any outlook for when it might be possible or is it simply not planned?
Many thanks,
Pete.