compiler.runtime.createDockerImage - Create a Docker image that contains MATLAB Runtime - MATLAB (original) (raw)
Create a Docker image that contains MATLAB Runtime
Since R2023b
Syntax
Description
compiler.runtime.createDockerImage([results](#mw%5F8d466ae9-8882-4055-9f0e-a691df8dd98f))
creates a MATLAB® Runtime Docker® image using a vector of compiler.build.Results
objectsresults
. The results
objects can be created by anycompiler.build
function.
compiler.runtime.createDockerImage([filepath](#mw%5Fac2be0e7-21b6-4663-bfc2-0c82af723d2c))
creates a MATLAB Runtime Docker image using a list of requiredMCRProducts.txt
files generated by MATLAB Compiler™.
compiler.runtime.createDockerImage(___,[Name,Value](#namevaluepairarguments))
creates a MATLAB Runtime Docker image with additional options specified as one or more name-value arguments. Options include the build folder, verbosity level, and image name.
[name](#mw%5F61b01167-26f6-4f02-a4b7-6b65e7a7d24a) = compiler.runtime.createDockerImage(___)
creates a MATLAB Runtime Docker image and returns the name of the image as a character vector.
Examples
Create a MATLAB Runtime Docker image that can run two standalone application Docker containers.
Install and configure Docker on your system.
Create two standalone applications usingcompiler.build.standaloneApplication
. Save the output from each function as a compiler.build.Results
object.
results1 = compiler.build.standaloneApplication('mymagic.m');
results2 = compiler.build.standaloneApplication('myapp.mlapp');
Create a MATLAB Runtime Docker image that can be used for both deployed standalone applications.
name = compiler.runtime.createDockerImage([results1,results2]);
Create a Docker image for each standalone application. Specify the name of the MATLAB Runtime image you created as an input to thecompiler.package.docker
function.
compiler.package.docker(results1,'RuntimeImage',name)
compiler.package.docker(results2,'RuntimeImage',name)
Deploy the Docker images. For details, see Package MATLAB Standalone Applications into Docker Images.
Requires MATLAB Compiler SDK™
Create a MATLAB Runtime Docker image that can run two microservice Docker containers.
Create two production server archives usingcompiler.build.productionServerArchive
.
results1 = compiler.build.productionServerArchive('addmatrix.m',... 'OutputDir','add');
results2 = compiler.build.productionServerArchive('eigmatrix.m',... 'OutputDir','eig');
Create a MATLAB Runtime Docker image that can be used for both microservices. Use name-value arguments to specify the image name and build folder.
compiler.runtime.createDockerImage(["add/requiredMCRProducts.txt",... "eig/requiredMCRProducts.txt"],'ImageName','micro-combo-image',... 'DockerContext','runtime')
Create a microservice Docker image for each production server archive. Specify the name of theMATLAB Runtime image you created as an input to thecompiler.package.microserviceDockerImage
function.
compiler.package.microserviceDockerImage(results1,... 'ImageName','add-micro','RuntimeImage','micro-combo-image');
compiler.package.microserviceDockerImage(results2,... 'ImageName','eig-micro','RuntimeImage','micro-combo-image');
Deploy the microservices. For details, see Create Microservice Docker Image.
Input Arguments
One or more paths to requiredMCRProducts.txt
, which is generated by MATLAB Compiler SDK.
Example: ["fun1/requiredMCRProducts.txt","fun2/requiredMCRProducts.txt"]
Name-Value Arguments
Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN
, where Name
is the argument name and Value
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose Name
in quotes.
Example:
Name of the base Docker image that is used in the FROM
line to create theMATLAB Runtime image, specified as a character vector or a string scalar. If this property is not specified, a base image with all required dependencies is created.
Example: 'BaseImage','matlab-deps'
Data Types: char
| string
Path to the build folder where the Docker image is built, specified as a character vector or a string scalar. The path can be relative to the current working directory or absolute.
If no path is specified, the function creates a build folder named_`[ImageName](#mw%5Ff63ad112-a2a9-4893-93a0-34d0161b7911)`_runtime
in the current working directory.
Example: 'DockerContext','./docker/magicruntime'
Data Types: char
| string
Flag to build the Docker image, specified as 'on'
or 'off'
, or as numeric or logical 1
(true
) or0
(false
). A value of 'on'
is equivalent to true
, and 'off'
is equivalent to false
. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.
- If you set this property to
'on'
, then the function will build the Docker image. - If you set this property to
'off'
, then the function will populate theDockerContext
folder without calling 'docker build
'.
Example: 'ExecuteDockerBuild','Off'
Data Types: logical
Name of the MATLAB Runtime Docker image, specified as a character vector or a string scalar. The name must comply with Docker naming rules. Docker repository names must be lowercase. If specified, this property is used as the name output argument.
If not specified, the default image name resembles the following:
matlabruntime/r2025a/update0/1000000000000000
Example: 'ImageName','magicruntime'
Data Types: char
| string
Since R2025a
Optional MATLAB Runtime dependencies to include in the installer, specified as one of the following:
'none'
— Option to not include any of the optional dependencies in the installer. Use this option to minimize the size of the generated installer. This option is the default behavior.'all'
— Option to include all of the optional dependencies in the installer, including graphical support.
Example: 'RuntimeDelivery','installer'
Data Types: char
| string
Output verbosity level, specified as one of the following options:
'verbose'
(default) — Display all screen output, including Docker output that occurs from the commands 'docker pull
' and 'docker build
'.'concise'
— Display progress information without Docker output'none'
— Do not display output.
Example: 'VerbosityLevel','concise'
Data Types: char
| string
Output Arguments
Name of the generated MATLAB Runtime Docker image, specified as a character vector. You can set the name using theImageName property.
Data Types: char
Version History
Introduced in R2023b