Unable to use Simulink when running inside docker

11 views (last 30 days)
Hello. I've recently tried to use Simulink with python through matlab. Due to some errors in linux, I ended up running matlab engine successfully after building with a Docker container by following this tutorial. I then edit the Dockerfile to select R2025a instead of R2023b
After that, I installed simulink inside my Dockerfile
ARG MATLAB_RELEASE=R2025a
# Build MATLAB image
FROM mathworks/matlab:R2025a
# Declare global
ARG MATLAB_RELEASE
# Necessary packages to run python3 properly
USER root
RUN apt-get update && \
apt-get install -y python3.12-dev python3.12-venv
RUN wget -O /mpm https://www.mathworks.com/mpm/glnxa64/mpm
RUN chmod +x /mpm
RUN /mpm install --release=$MATLAB_RELEASE --destination=/opt/matlab Simulink 'Control System Toolbox'
USER matlab
RUN python3.12 -m pip install numpy --break-system-packages
# Install MATLAB Engine API for Python
RUN /bin/sh -c 'cd /opt/matlab/$MATLAB_RELEASE/extern/engines/python && sudo python3 setup.py install'
Where small_test.m file is the following:
function [] = small_test()
si = Simulink.SimulationInput("smith_water_cr")
end
This give me the following error inside matlab shell:
>> small_test
Simulink.SimulationInput requires Simulink.
Error in small_test (line 2)
si = Simulink.SimulationInput("smith_water_cr");
Using load_system also gives me the same error:
function [] = small_test()
load_system('simulink')
end
Then:
>> small_test
load_system requires one of the following:
RF Toolbox
Simulink
Also some notes, here is my file structure:
small_test.m
smith_water_cr.slx
also please notice that I can run just fine if I use directly inside the shell:
matlab@f6fd79e935a8:~/Documents/MATLAB$ matlab
% ...
>> si = Simulink.SimulationInput("smith_water_cr")
si =
SimulationInput with properties:
ModelName: "smith_water_cr"
% etc

Answers (1)

Jacob Mathew
Jacob Mathew on 16 Jun 2025
Hey ,
MathWorks has a dedicated GitHub page on MATLAB Docker Images and creating custom docker images based on the version, products and support packages you need. This would be the ideal starting point:
Spedifically, you can set the MATLAB_PRODUCT_LIST variable in the dockerfile to the list of addtional products or support packages you need. In the above code you have mentioned Simulink and Control System Toolbox. You can set that as follows:
ARG MATLAB_PRODUCT_LIST="MATLAB Simulink Control_System_Toolbox"
You can customise the dockerfile as mentioned above and add the necessary command to install Python and Python engine for MATLAB as mentioned in the MATLAB Answers Post you referenced. Additionally, the sample dockerfile in the GitHub repository also installs the necessary dependencies needed for MATLAB Package Manager (mpm) to run without hiccups.

Products


Release

R2025a

Community Treasure Hunt

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

Start Hunting!