Main Content

MATLAB Container on Docker Hub

Access MATLAB® in the cloud or in server environments by using the prebuilt MATLAB container image available on Docker Hub. Use the MATLAB container to run MATLAB in cloud environments such as AWS® or Microsoft® Azure®. If you instead want to create and customize a MATLAB container image from a Dockerfile, see Create a Custom MATLAB Container. For more information about containers, see What is a Container?.

Contents of the Container

The MATLAB container image includes:

  • An Ubuntu® base image

  • MATLAB (without additional toolboxes)

  • Dependencies to run all MathWorks® products

  • Software to enable interaction with the MATLAB desktop

Requirements

To use the MATLAB container image, you need:

  • A host machine with Docker® installed.

  • A MATLAB license that is:

    • Valid for all the MathWorks products installed in the container.

    • Linked to a MathWorks Account.

    • Configured for cloud use. Individual and Campus-Wide licenses are already configured. For other license types, contact your license administrator. To identify your license type and administrator, log in to your MathWorks Account. If you are an administrator, see Administer Network Licenses.

  • If you have a Concurrent license, you must supply the port number and DNS address of the network license manager when you run the container. Add this option to the docker run command when you start the container: -e MLM_LICENSE_FILE=27000@MyLicenseServer.

Quick Start Guide for MATLAB Container

This section shows how to run the MATLAB container and launch an interactive MATLAB session either in browser mode or using a VNC client. For a complete list of commands to start the MATLAB container, including how to use MATLAB in batch mode, see MATLAB Container Image on Docker Hub.

Pull Container Image

To download the MATLAB container image onto the host machine, run this command in the command line. You must replace the tag r20XYz with the specific MATLAB release name, for example, r2022a. Downloading and extracting the container image can take some time.

docker pull mathworks/matlab:r20XYz

Run Container in Browser Mode

Run the MATLAB container using this command:

docker run -it --rm -p 8888:8888 --shm-size=512M mathworks/matlab:r20XYz -browser

  • -it runs the container in interactive mode.

  • --rm deletes the container when it is closed.

  • -p 8888:8888 exposes port 8888 for the web browser connection.

  • --shm-size=512M sets the size of the shared memory to 512 MB, which is required for MATLAB to run correctly.

  • :r20XYz specifies release version R20XYz of the MATLAB container.

  • -browser specifies the option for interacting with MATLAB through a web browser.

Running the command prints a URL to your terminal. To access MATLAB, enter the URL into a web browser. If prompted to do so, enter credentials for a MathWorks account associated with a MATLAB license.

Note

  • Docker images support the -browser option from release version R2022a on. To access MATLAB in a web browser in custom docker images or older MATLAB docker images, see Examples.

Run Container in VNC Mode

You can also run the MATLAB container in VNC mode. Doing so allows you to install toolboxes or update MATLAB. For more details, see Install Updates, Toolboxes, Support Packages, and Add-Ons in Containers.

Run the MATLAB container in VNC mode by entering this command:

docker run --init -it --rm -p 5901:5901 -p 6080:6080 --shm-size=512M mathworks/matlab:r20XYz -vnc

  • -p 5901:5901 exposes port 5901 for the VNC connection.

  • -p 6080:6080 exposes port 6080 for the web browser connection.

  • -vnc specifies the option to interact with MATLAB through a VNC client.

To connect to the desktop where you can open MATLAB:

  • Use a VNC client to connect to display 1 of the Docker host machine (localhost:1).

  • If you do not have a VNC client, point a browser to port 6080 of the Docker host machine running this container (http://localhost:6080).

If your container is not running on your local machine, replace localhost with the fully qualified domain name (FQDN) of the computer on which the container is running.

The default VNC password is matlab.

For a full list of options and environment variables that you can use to start the container, run the container with the -help flag:

docker run -it --rm mathworks/matlab:r20XYz -help

For more information about configuring a MathWorks container image using environment variables, see Configure Containers.

Related Topics

External Websites