exportToFMU function in docker container error
39 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Michal
el 10 de Nov. de 2025 a las 16:09
Respondida: Tao Cheng
el 12 de Nov. de 2025 a las 17:38
I'm using Docker with mathworks/matlab-deps as a base image and I created the dockerfile following instructions at this site to create my custom dockerfile that installs necessary toolboxes and packages. I installed into the image the FMU_Builder_For_Simulink support package and also MATLAB_Coder, Simulink_Coder, MATLAB_Compiler, Simulink_Compiler and Simulink_Report_Generator.
The dockerfile is here:
FROM mathworks/matlab-deps:${MATLAB_RELEASE}
# Declare build arguments to use at the current build stage.
ARG MATLAB_RELEASE
ARG MATLAB_PRODUCT_LIST
ARG MATLAB_INSTALL_LOCATION
ARG LICENSE_SERVER
ARG INSTALLATION_USER
# Install mpm dependencies.
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install --no-install-recommends --yes \
gcc g++ \
wget \
ca-certificates \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
# Add "matlab" user and grant sudo permission.
RUN adduser --shell /bin/bash --disabled-password --gecos "" ${INSTALLATION_USER} \
&& echo "${INSTALLATION_USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${INSTALLATION_USER} \
&& chmod 0440 /etc/sudoers.d/${INSTALLATION_USER}
# Set user and work directory.
USER ${INSTALLATION_USER}
WORKDIR /home/${INSTALLATION_USER}
# Run mpm to install MATLAB in the target location and delete the mpm installation afterwards.
# If mpm fails to install successfully, then print the logfile in the terminal, otherwise clean up.
# Pass in $HOME variable to install support packages into the user's HOME folder.
RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \
&& chmod +x mpm \
&& sudo HOME=${HOME} ./mpm install \
--release=${MATLAB_RELEASE} \
--destination=${MATLAB_INSTALL_LOCATION} \
--products ${MATLAB_PRODUCT_LIST} \
|| (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \
&& sudo rm -rf mpm /tmp/mathworks_root.log \
&& sudo ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab
# Note: Uncomment one of the following two ways to configure the license server.
# Option 1. Specify the host and port of the machine that serves the network licenses
# if you want to store the license information in an environment variable. This
# is the preferred option. You can either use a build variable, like this:
# --build-arg LICENSE_SERVER=27000@MyServerName or you can specify the license server
# directly using: ENV MLM_LICENSE_FILE=27000@flexlm-server-name
ENV MLM_LICENSE_FILE=$LICENSE_SERVER
# Option 2. Alternatively, you can put a license file into the container.
# Enter the details of the license server in this file and uncomment the following line.
# COPY network.lic ${MATLAB_INSTALL_LOCATION}/licenses/
# The following environment variables allow MathWorks to understand how this MathWorks
# product (MATLAB Dockerfile) is being used. This information helps us make MATLAB even better.
# Your content, and information about the content within your files, is not shared with MathWorks.
# To opt out of this service, delete the environment variables defined in the following line.
# To learn more, see the Help Make MATLAB Even Better section in the accompanying README:
# https://github.com/mathworks-ref-arch/matlab-dockerfile#help-make-matlab-even-better
# ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=MATLAB:DOCKERFILE:V1
ENTRYPOINT ["matlab"]
CMD [""]
I built the image. Then I wanted to use the function exportToFMU to build FMU for Linux inside the container, so inside the container in the matlab terminal I ran the command:
exportToFMU('model', 'FMIVersion', '2.0', 'FMUType', 'CS', 'CreateModelAfterGeneratingFMU', 'off');
The output looked like this:
Setting System Target to FMU Co-Simulation for model 'model'.
Setting Hardware Implementation > Device Type to 'MATLAB Host' for model 'model'.
### 'GenerateComments' is disabled for Co-Simulation Standalone FMU Export.
Fontconfig warning: "/usr/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"
Fontconfig warning: "/usr/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"
Build Summary
Top model targets built:
Model Action Rebuild Reason
=================================================================
model Failed Code generation information file does not exist.
0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 25.552s
Error using script
Printing is not supported in -nodisplay mode.
It looks like there is a problem with the exportToFMU function when using -nodisplay mode of matlab. How can I make this work?
Thank you for your help!
0 comentarios
Respuesta aceptada
Tao Cheng
el 12 de Nov. de 2025 a las 17:38
Hi Michal,
The error "Printing is not supported in -nodisplay mode." seems to be related to Simulink's print command: https://www.mathworks.com/help/simulink/ug/print-from-the-matlab-command-line.html
Can you try turning off the icon generation option during FMU Export? Something like "exportToFMU(..., 'AddIcon', 'off')" may help.
HTH,
TC
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!