Main Content

Install MATLAB and Add-Ons in Containers in an Offline Environment

Build and customize a Docker® container image for MATLAB®, toolboxes, and support packages in an offline environment. Use this solution only if you need to install MATLAB, toolboxes, and support packages in an air-gapped environment.

Otherwise, if you want to create a Docker container image with a custom MATLAB installation in a Linux® environment, see Create a Custom MATLAB Container.

Alternatively, for an out-of-the-box MATLAB container image that you can pull from Docker Hub directly, see MATLAB Container on Docker Hub.

Requirements

  • A host machine with Docker (version >= 20.10) and Git™ installed.

  • A MATLAB license administered via a network license manager that meets the following conditions:

  • To license MATLAB in the container, you must supply the port number and DNS address of the network license manager. You can add this information either when you build the container image or when you start the container.

    • To set this information when you build the container image, add an option of the following form to the docker build command:

      --build-arg LICENSE_SERVER=27000@MyLicenseServer

      Alternatively, you can use a license file to provide the location of the license manager when you build the container image. If you want to use a Network Named license type with the container image, you must first add the user name in the Dockerfile before running the docker build command. After building the container image, run the container with the specific user name associated with the license. For more information, see Use a Network Named License in a Container.

    • To set this information when you run the container image, add an option of the following form to the docker run command:

      -e MLM_LICENSE_FILE=27000@MyLicenseServer

Use a Network Named License in a Container

If you are using a Network Named license with the container, you must run the container with the specific user name associated with the license. Users cannot be added to containers after the container image is built, so be sure to build any user name you will potentially need to use into the Dockerfile before you build the container image.

To define users for the container, add users in the Dockerfile and then run the container as a specified user. The following Dockerfile command adds the specified user to the container:

RUN useradd -ms /bin/bash <USERNAME>

This next Dockerfile command sets the container to run as the specified user:

USER <USERNAME>

The -u runtime flag overrides any USER command that was built into the container. You can use this to change the user of the container at runtime. For more information, see the Docker documentation.

Build and Customize Container Image

To build and customize a Docker container image with MATLAB and its toolboxes in an offline environment, follow the instructions in this GitHub® repository:

The solution uses two Docker images. The first image (archive image) contains the installation files that are required by MATLAB Package Manager (mpm) to install from source. The second image (product image) uses the archive image to get the installation files for MATLAB, toolboxes and support packages that you want to install.

Related Topics

External Websites