Running Matlab/Simulink simulation inside Windows Docker container

13 views (last 30 days)
I'm trying to make Matlab Simulink simulations to run inside a Windows Docker container. The simulations are run using pytest and matlabengine Python module. The Windows container is commandline-only, based on windowsservercore-ltsc2019. The problem I'm stuck with is that matlab.engine.start_matlab() -call just hangs without giving any error message or other output. And yes, the simulation works as expected when run outside the container in the host system.
I also noticed Mathworks only offers linux-based container in the Github-repository. Is there some fundamental problem with running Matlab inside Windows container? I managed to run the installation ok to my best understanding. At least the installation process didn't give any error messages in the log.
  1 Comment
Michael
Michael on 29 Apr 2025
Hi @Jukka,
As you may be aware, Windows containers come in three general flavours: Server Nano, Server Core, and Server. They are all designed with different functionality with Windows server being the most fully featured. One of the major things that is included with the Windows Server container is full GUI APIs allowing for tasks that require virtualised displays.
Given this I would suggest trying the full Windows Server base image as an initial step that may work without any further modifications.
There is also an Issue open on our matlab-dockerfile GitHub page related to the availablity of a windows based reference Dockerfile. We will be posting any updates on this here and so I would reccomend folloing the issue. You can find it here: No Windows docker reference for non-interactive / matlab-batch · Issue #134 · mathworks-ref-arch/matlab-dockerfile
Hopefully this helps and we would love to hear about your experiences with and usecases for MATLAB in Windows Docker

Sign in to comment.

Accepted Answer

Jukka
Jukka on 6 Jun 2025
In the end I managed to solve the issue.
It was about licensing server discovery. I had to modify the license file to use direct IP address instead of DNS name of our licensing server instance. I still have no idea what causes this as our other services work just fine from the container with using the DNS name, but at least I have a workaround.

More Answers (1)

Joe
Joe on 5 Jun 2025
One of the big issues with Matlab running in containers is that it was designed to run as a GUI. When matlab calls hang in docker it is often trying to open a GUI and failing or waiting for user input. Without a link I cannot be sure but I willing to bet the linux containers you reference have a number of workarounds for this issue.
I am not familiar with your exact problem but you may want to verify everything is running headless and using matlab -batch when possible. When debugging GUI stuff I often run my dockerfile commands on a fresh install locally and see where GUIs get popped up, which is often, then I know the container will have issues at that step.
Hope this helps

Categories

Find more on Containers in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!