Docker Community Forums

Share and learn in the Docker community.

Run exe in windows container using python


I am working on executing an exe file (notepad.exe) inside windows container using python.

I have copied these in my container:

  • exe file

  • dockerfile that calls python script

  • python script that runs exe

When I build and run these, Its not showing any error. But, the exe is also not running. Am I doing anything wrong? Can notepad.exe open in host machine or do I have to check the processlist in container to check whether it is running or not?

It would be easier to help if you’d share the details of your build & run and how did You conclude that the exe is not running?

I have attached the screenshot of run & build.

This is the python code I am executing.

import os

As notepad is not opening, I thought that it is not executing. Actually, I want to execute an exe file and take the memory dump of Windows container. Can you please tell me what to do for getting the memory dump? Also,how will I know that the exe is executing or not?

Make sure you have notepad.exe in Your Win container, and specify full path like os.startfile(“C:\windows\system32\notepad.exe”)
If there isn’t copy to the image.

The exe, python file and docker file are inside the container as well. I have mounted my E:\input\ path to the container C:\data.

Did you try os.startfile("<path to exe>\notepad.exe") ?

this part was cut out so i repeat : os.startfile("\path-to-the-exe\notepad.exe")

Yes. But, its showing the error FileNotFoundError: [WinError 2] The system cannot find the file specified:

I am executing the docker commands in the powershell and the path is set as E:\input\Automation(as shown in the above screenshot). That path has all files. So, is it mandatory to give the full path? When I don’t give any path, it’s not showing any error.