matlab-dockerfile开源项目

我要开发同款
匿名用户2021年11月23日
58阅读
所属分类、应用工具、科研计算工具
授权协议View license

作品详情

CreateaMATLABContainerImageRequirements

YoumustperformthesestepsonaLinuxplatform.Beforestarting,youmustinstallthefollowingontheclientplatform

DockerGitIntroduction

ThefollowingstepsguideyouthroughtheprocessofcreatingaDockercontainerimagethatcontainsaLinuxenvironmentwithaMATLABinstallation.UsethecontainerimageasascalableandreproduciblemethodtodeployMATLABinavarietyofsituationsincludingcloudsandclusters.

Step1.ClonethisRepository

ClonethisrepositorytoyourLinuxclientusing

gitclonehttps://github.com/mathworks-ref-arch/matlab-dockerfile.git

Insidetheclonedrepository,createasubdirectorynamedmatlab-install

Step2.ChooseMATLABInstallationMethod

ToinstallMATLABintothecontainerimage,chooseaMATLABinstallationmethod.YoucanuseMATLABinstallationfilesoraMATLABISOimage.

MATLABInstallationFiles

Toobtaintheinstallationfiles,youmustbeanadministratorforthelicenselinkedwithyourMathWorksaccount.

FromtheMathWorksDownloadspage,selectthedesiredversionofMATLAB.DownloadtheInstallerforLinux.FollowthestepsatDownloadProductsWithoutInstallation.Specifythelocationofthematlab-installsubdirectoryoftheclonedrepositoryasthepathtothedownloadfolder.SelecttheinstallationfilesfortheLinux(64-bit)versionofMATLAB.Selecttheproductsyouwanttoinstallinthecontainerimage.Confirmyourselectionsandcompletethedownload.MATLABISOFromtheMathWorksDownloadspage,selectthedesiredversionofMATLAB.UndertheRelatedLinksheading,clickthelinktogettheISOimageforthechosenMATLABversion.DownloadtheISOimagefortheLinux.ExtracttheISOintothematlab-installsubdirectoryoftheclonedrepository.Step3.ObtaintheLicenseFileandFileInstallationKeyLogintoyourMathWorksaccount.Selectthelicenseyouwishtousewiththecontainer.SelecttheInstallandActivatetab.Selectthelink“ActivatetoRetrieveLicenseFile”.ClickthedownloadlinkundertheGetLicenseFileheading.SelecttheappropriateMATLABversionandclickContinue.Attheprompt“Isthesoftwareinstalled?”select“No”andclickContinue.CopytheFileInstallationKeyintoasafelocation.Step4.DefineInstallationParametersMakeacopyofthefileinstaller_input.txtinthematlab-installfolder.Movethecopyuponedirectorylevel,intotherootdirectoryoftheclonedrepository.Renamethefiletomatlab_installer_input.txt.Openmatlab_installer_input.txtinatexteditorandeditthefollowingsections:fileInstallationKeyPasteyourFileInstallationKeyanduncommenttheline.agreeToLicenseSetthevaluetoyesanduncommenttheline.Specifyproductstoinstall.Uncommentthelineproduct.MATLABtoinstallMATLAB.Uncommentthecorrespondinglineforeachadditionalproductyouwanttoinstall.Ifyouarenotlicensedtouseaproduct,uncommentingthelinedoesnotinstalltheproductinthecontainer.YourFileinstallationKeyidentifiestheproductsyoucaninstall.(Optional)SpecifyrequireddependenciesintheDockerfile.EdittheDockerfileanduncommentthecorrespondinglineforeachdependencyyouwanttoadd.Formoreinformation,seeOptionalDependencies.Step5.BuildImage

Usethedockerbuildcommandtobuildtheimage,using.tospecifythisfolder.Runthecommandfromtherootdirectoryoftheclonedrepository.Useacommandoftheform:

dockerbuild-tmatlab:r2020a--build-argLICENSE_SERVER=27000@MyServerName.

Note:TheLICENSE_SERVERbuildargumentisNOTusedduringthebuildbutbysupplyingithereduringbuilditgetsincorporatedintothecontainersothatMATLABinthecontainerknowshowtoacquirealicensewhenthecontainerisrun

TobuildapreviousversionofMATLAB,forexampleDockerfile.R2019b,useacommandoftheform

dockerbuild-fDockerfile.R2019b-tmatlab:r2019b--build-argMATLAB_RELEASE=R2019b--build-argLICENSE_SERVER=27000@MyServerName.

Youmustsupplyatagfortheimageusingthe-toption,forexample,matlab:r2020a.Thetagnamestherepositoryforlateruseanddeployment.Specifythelocationofthenetworklicencemanagerusing--build-argLICENSE_SERVER=27000@MyServerName.Replace27000@MyServerNamewiththeportandlocationofyourlicensemanager.Alternatively,youcanusealicense.datornetwork.licfiletoprovidethelocationofthelicensemanager.Formoreinformation,seeUseaLicenseFiletoBuildImage.

FortheR2019bDockerfileyoumustalsospecifytheMATLABreleaseusing--build-argMATLAB_RELEASE=R20xxx,whereR20xxxreferstoaMATLABreleaseyouaretryingtobuild.

Step6.RunContainer

Usethedockerruncommandtorunthecontainer.Useacommandoftheform:

dockerrun-it--rmmatlab:r2020a-itoptionrunsthecontainerinteractively.--rmoptionautomaticallyremovesthecontaineronexit.

AnyextraargumentsafterthecontainertagarepasseddirectlyascommandlineargumentstotheMATLABprocessinsidethecontainer.Forexample,thefollowingcommandprintshelloworldinMATLABandthenexits.

dockerrun-it--rmmatlab:r2020a-r"disp('helloworld');exit"OptionalDependencies

Forsomeworkflowsandtoolboxes,youmustspecifydependencies.Youmustdothisifyouwanttodoanyofthefollowingtasks.

InstallextendedlocalizationsupportforMATLABPlaymediafilesfromMATLABRunanetworklicensemanagerinsidethecontainerGeneratecodefromSimulinkUsemexfunctionswithgcc,g++,orgfortranUsetheMATLABEngineAPIforCandFortranUsethePolyspace32-bittcccompiler

EdittheDockerfileanduncommenttherelevantlinestoinstallthedependencies.

UseaLicenseFiletoBuildImage

Ifyouhavealicense.datfilefromyourlicenseadministrator,youcanusethisfiletoprovidethelocationofthelicensemanagerforthecontainerimage.

Openthelicense.datfile.CopytheSERVERlineintoanewtextfile.Beneathit,addUSE_SERVER.Thefileshouldnowlooksomethinglikethis:SERVERServer10123abcd012312345USE_SERVERSavethenewtextfileasnetwork.licintherootdirectoryoftheclonedrepository.OpentheDockerfile,andcommentthelineENVMLM_LICENSE_FILEUncommentthelineADDnetwork.lic/usr/local/MATLAB/$MATLAB_RELEASE/licenses/Runthedockerbuildcommandwithoutthe--build-argLICENSE_SERVER=27000@MyServerNameoption.Useacommandoftheformdockerbuild-tmatlab:r2020a.

Formoreinformationaboutlicensefiles,seeWhatarethedifferencesbetweenthelicense.lic,license.dat,network.lic,andlicense_info.xmllicensefiles?

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论