Hi Nils,
Question - 1: How can I run a MATLAB (*.m) file in this Linux docker with a terminal command?
To run MATLAB (*.m) files on a Linux system via a Docker container, you would need a MATLAB installation within the container. However, if you don't have MATLAB installed and only have the MATLAB Compiler Runtime (MCR), you can still run compiled MATLAB applications but not the raw .m files directly.
If you have MATLAB installed in your Docker container, you can run an .m file from the terminal with the following command:
matlab -batch "run('/path/to/your_script.m')"
Question - 2: Is it even possible to run MATLAB files with the MCR?
Yes, it is possible to run MATLAB files with the MCR. Here are the stepwise guide to achieve this:
Step-1: Create a docker file with the following commands:
- Pull a base MCR image.
- Set the LD_LIBRARY_PATH environment variable to the MCR installation directories, using the ENV instruction.
- Copy the compiled MATLAB executable to the image, using the COPY instruction.
- Run the compiled MATLAB executable, using the CMD instruction.
Step-2: Build the image using the Dockerfile.
- Navigate to the directory containing your Dockerfile using terminal.
- Run the below command.
docker build -t <new_image_name_of_choice> .
Step-3: You can then run the docker container with the below command:
docker run -it --rm --shm-size=512M <your_image_name>
Please refer to the following MathWorks documentation for more information on:
Hope this helps!