Main Content

compiler.runtime.createDockerImage

Create a Docker image that contains MATLAB Runtime

Since R2023b

Description

example

compiler.runtime.createDockerImage(results) creates a MATLAB® Runtime Docker® image using a vector of compiler.build.Results objects results. The results objects can be created by any compiler.build function.

example

compiler.runtime.createDockerImage(filepath) creates a MATLAB Runtime Docker image using a list of requiredMCRProducts.txt files generated by MATLAB Compiler™.

example

compiler.runtime.createDockerImage(___,Name,Value) 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.

example

name = compiler.runtime.createDockerImage(___) creates a MATLAB Runtime Docker image and returns the name of the image as a character vector.

Examples

collapse all

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 using compiler.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 the compiler.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 using compiler.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 the MATLAB Runtime image you created as an input to the compiler.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 (MATLAB Compiler SDK).

Input Arguments

collapse all

One or more build results created by a compiler.build function, such as compiler.build.standaloneApplication or compiler.build.productionServerArchive (MATLAB Compiler SDK), specified as a vector of compiler.build.Results objects.

Example: [results1,results2]

One or more paths to requiredMCRProducts.txt, which is generated by MATLAB Compiler.

Example: ["fun1/requiredMCRProducts.txt","fun2/requiredMCRProducts.txt"]

Name-Value Arguments

Specify optional pairs of arguments as Name1=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 the MATLAB 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 ImageNameruntime 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) or 0 (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 the DockerContext 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/r2023a/update0/1000000000000000

Example: 'ImageName','magicruntime'

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

collapse all

Name of the generated MATLAB Runtime Docker image, specified as a character vector. You can set the name using the ImageName property.

Data Types: char

Version History

Introduced in R2023b