Windows Forms Applications in Container

I’m exploring docker now there is native container support within Windows 10 itself. Can you run Windows Form applications within a windows 10 nanoserver image?

My current build:

  1. Windows 10 Enterprise + Anniversary update (HyperV Enabled).
  2. Docker version 1.12.1, build 23cf638
1 Like

You cannot, Docker Windows containers don’t support GUI apps yet.

Thank you @friism for the speedy reply. That answers my next question about using MSI installers via a GUI for applications. Do we know if GUI support is on the backlog?

I too would like to know if GUI support is on the backlog. I’d love to run some browsers for Karma testing and stuff. I feel like it’s pretty important that they support this feature.

Does docker support GUI apps on non windows platforms ? e.g. on ubuntu ?

For my purposes i`m installing in dockerfile
apt-get install -y
mono-complete
mono-mcs
mono-xsp4
libxtst6 libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 xvfb

then run container, open via bash, and after:

Xvfb :99
export DISPLAY=:99
mcs -pkg:dotnet someFile.cs
mono someFile.exe

1 Like

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 :slight_smile:

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:

  1. Can I interact with a WinForm running in a container based on the MS server image? (what commands/parameters have I missed and need?)

  2. 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.

Dear Pavel, can you please give more details, what are your details about? What kind of app are you creating, which Gui-Framework, etc.
Thank you!

@ Michael FriisDoes, I understand Docker don’t support GUI apps yet…

Could you please advise that are there any road map items to enable Docker Windows Container to support .NET WinForms C# applications?
I see tremendous values for this usecase with enterprise customers and .net developers to retain existing investments on .NET winforms apps and promotes acceleration for containerizing legacy .net windows applications. Please review and advise!

The MS’ answer to your question published on 25th Jan 2019 was “No, it isn’t possible”.

You can’t run desktop apps in Docker because there’s no UI integration between the Docker platform and the Windows host. That rules out running Windows Forms or Windows Presentation Foundation (WPF) apps in containers[…]

I’m afraid it hasn’t change since then.

Oh sorry. Topic starter asked about wIN forms inside windows image. We have run wEB Forms inside Linux container, so my answer is not relevant. I`m apologize for the confusion.