一、准备文件和安装包
1.本次介绍是在容器里安装R2022a_Linux,环境信息为一个镜像、MATLAB的ISO文件等。
2.配置静默安装文件
#Descriptive information
#This is to tell the installation script that you agree to the terms of the installation
agreeToLicense=yes
#Here's how to fill in the key
fileinstallationKey=50874******14209-*******33348-
#This tells the installation script where you want to install it
destinationFolder=/matlab
#Here's how to tell the installation script where your license file is in license.lic
licensePath=/store/license.lic
#Here is to tell the installation script what you want to install
product.Embedded_Coder
product.MATLAB
product.Simulink
product.Simulink_Coder
product.Stateflow
二、配置容器
1.创建容器
run :创建一个新的容器并运行一个命令
-d 后台运行容器,并返回容器ID
-i: 以交互模式运行容器,通常与 -t 同时使用;
--privileged=true是要以root权限启动容器
2.在容器里创建文件用于存放MATLAB
进入容器,执行命令mkdir -p matlab/store
在matlab文件夹里存放R2022a_Linux.iso解压后的文件
在store里存放install_input.txt、license.lic、libmwlmgrimpl.so
3.使用命令将本地的文件拷贝至容器里
#使用docker cp进行拷贝,将install_input.txt拷贝至store
docker cp ./installer_input.txt e271602be:/matlab/store/
docker cp ./libmwlmgrimpl.so e271602be:/matlab/store/
docker cp ./license.lic e271602be:/matlab/store/
docker cp ./R2022a_Linux.iso e271602be:/matlab/
docker cp用于主机与容器之间的数据拷贝
docker cp [OPTIONS] PC_PATH|- CONTAINER:DEST_PATH
三、安装MATLAB
1.安装解压文件用于解压iso文件
#在ubuntu容器当中需要先更新apt-get之后才能找到软件包
apt-get update
apt-get install -y p7zip-full
2.解压R2022a_Linux.iso
7z x R2022a_Linux.iso -o/matlab
3.替换installer_input.txt文件
mv /store/installer_input.txt /matlab
替换文件可以有多种方式,这里使用mv直接将原始文件覆盖掉
4. 修改matlab文件夹的权限
chmod a+x -R /matlab
5.使用静默的方式安全matlab
cd /matlab
./install -inputFile ./install_input.txt
6.验证
mv matlab/bin/glnxa64/matlab_startup_plugins/lmgrimpl
rm -r libmwlmgrimpl.so
mv /store/libmwlmgrimpl.so ./
7.运行matlab
cd /matlab/bin
./matlab -nodisplay