Simulink Unavailable inside of Docker Container
Closed this issue · 5 comments
Issue: When running the new_system()
method within a container I get the following error:
Traceback (most recent call last):
File "/app/main.py", line 143, in <module>
generate_simulink_model(fname)
File "/app/main.py", line 67, in generate_simulink_model
model(nargout=0, stdout=out)
File "/usr/local/lib/python3.10/dist-packages/matlab/engine/matlabengine.py", line 71, in __call__
_stderr, feval=True).result()
File "/usr/local/lib/python3.10/dist-packages/matlab/engine/futureresult.py", line 67, in result
return self.__future.result(timeout)
File "/usr/local/lib/python3.10/dist-packages/matlab/engine/fevalfuture.py", line 82, in result
self._result = pythonengine.getFEvalResult(self._future,self._nargout, None, out=self._out, err=self._err)
matlab.engine.MatlabExecutionError:
File /app/out/<FILE>.m, line 8, in <FILE>
Undefined function 'new_system' for input arguments of type 'char'.
When running the the method through the shell within the container I get an error stating that simulink is not installed.
Discussion: I have tried installing matlab and simulink from scratch but still get the same result. I've tried searching for independent install packages for simulink only, but couldn't find the desired package.
Recommendation: Mathworks should offer an official simulink container for use in cloud deployments.
@TheMagicNacho I did the following to ensure that Simulink was installed and running in a docker container - I wonder if you could try the same to confirm at your end.
First get a clean copy of this repo:
jlmartin@vdi-dd1ah-053:/tmp$ mkdir issue101
jlmartin@vdi-dd1ah-053:/tmp$ cd issue101/
jlmartin@vdi-dd1ah-053:/tmp/issue101$ git clone https://github.com/mathworks-ref-arch/matlab-dockerfile.git
Cloning into 'matlab-dockerfile'...
remote: Enumerating objects: 467, done.
remote: Counting objects: 100% (258/258), done.
remote: Compressing objects: 100% (102/102), done.
remote: Total 467 (delta 130), reused 216 (delta 111), pack-reused 209
Receiving objects: 100% (467/467), 147.74 KiB | 5.68 MiB/s, done.
Resolving deltas: 100% (220/220), done.
jlmartin@vdi-dd1ah-053:/tmp/issue101$ cd matlab-dockerfile/
Next, build a container from this that has the products MATLAB and Simulink:
jlmartin@vdi-dd1ah-053:/tmp/issue101/matlab-dockerfile$ docker build --build-arg MATLAB_PRODUCT_LIST="MATLAB Simulink" -t issue-101 .
[+] Building 0.7s (10/10) FINISHED docker:default
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 4.38kB 0.0s
=> [internal] load metadata for docker.io/mathworks/matlab-deps:r2024a 0.5s
=> [auth] mathworks/matlab-deps:pull token for registry-1.docker.io 0.0s
=> [1/5] FROM docker.io/mathworks/matlab-deps:r2024a@sha256:dbf6fc2920e75a733d28db761ab5f358b2a9f359274c12c3371b 0.0s
=> CACHED [2/5] RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install --no-inst 0.0s
=> CACHED [3/5] RUN adduser --shell /bin/bash --disabled-password --gecos "" matlab && echo "matlab ALL=(ALL 0.0s
=> CACHED [4/5] WORKDIR /home/matlab 0.0s
=> CACHED [5/5] RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && chmod +x mpm && sudo HOME=${HOM 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:35506c09b34f8dc924c0d40271b476ad8602b25a1a48bcfea06d86b9cd36f7a7 0.0s
=> => naming to docker.io/library/issue-101
Copy across a license file that points to an appropriate server to license MATLAB:
jlmartin@vdi-dd1ah-053:/tmp/issue101/matlab-dockerfile$ cp /tmp/licenses/license.dat .
Finally run the container and show that new_system
is there and works without error:
jlmartin@vdi-dd1ah-053:/tmp/issue101/matlab-dockerfile$ docker run -it --rm -v ./license.dat:/opt/matlab/r2024a/licenses/license.dat issue-101
MATLAB is selecting SOFTWARE rendering.
< M A T L A B (R) >
Copyright 1984-2024 The MathWorks, Inc.
R2024a Update 1 (24.1.0.2568132) 64-bit (glnxa64)
March 28, 2024
To get started, type doc.
For product information, visit www.mathworks.com.
>> which new_system
built-in (/opt/matlab/r2024a/toolbox/simulink/core/api/new_system)
>> new_system
>>
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 24.1.0.2568132 (R2024a) Update 1
MATLAB License Number: unknown
Operating System: Linux 5.10.0-28-amd64 #1 SMP Debian 5.10.209-2 (2024-01-31) x86_64
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 24.1 (R2024a)
Simulink Version 24.1 (R2024a)
I suspect you have a container that didn't install Simulink somehow.
@josmartin Thanks! I'm trying it out with our particular environment, I'll update as things progress.
@josmartin, does the MPM have a method to bypass ssl verification?
@TheMagicNacho No - to ensure you can do that you should make sure that you have apt-get install ca-certificates
or that you have installed any intermediate intercepting proxies CA certificates in the container before calling mpm
. We need to undertake a secure install so we always validate SSL certs.
@josmartin thank you for your help!
For historical purposes:
The most efficient means to add additional products into an existing container is using this code block:
RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \
&& chmod +x mpm \
&& EXISTING_MATLAB_LOCATION=$(dirname $(dirname $(readlink -f $(which matlab)))) \
&& sudo HOME=${HOME} ./mpm install \
--destination=${EXISTING_MATLAB_LOCATION} \
--release=${MATLAB_RELEASE} \
--products ${ADDITIONAL_PRODUCTS} \
|| (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \
&& sudo rm -rf mpm /tmp/mathworks_root.log ${HOME}/.MathWorks