Access MATLAB® on the cloud or in server environments by using the MATLAB container available on Docker Hub. The MATLAB container provides a simple and flexible solution to run MATLAB in cloud environments such as AWS® or Microsoft® Azure®. For more information on containers, see What is a Container?.
The MATLAB container includes:
Ubuntu® base image
MATLAB (no additional toolboxes)
Dependencies to run all MathWorks® products
Software to enable interaction with the MATLAB desktop
To use the MATLAB container, you need:
A host machine with Docker® installed.
A MATLAB license that meets the following conditions:
Valid for all the MathWorks products installed in the container.
Current on Software Maintenance Service (SMS).
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. You can identify your license type and administrator by viewing your MathWorks Account. Administrators can consult MATLAB Licensing in the Cloud.
If you have a Concurrent license type, you must supply the port number and
DNS address of the network license manager when you run the container. Add
an option of the following form to the docker run command
when you start the
container:
-e MLM_LICENSE_FILE=27000@MyLicenseServer
This section shows an example of how to run the MATLAB container and access the MATLAB desktop from a web browser. 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.
To download the MATLAB container image onto the host machine, run this code:
docker pull mathworks/matlab:r20XYz
You must replace the tag r20XYz with the specific
MATLAB release name, for example, r2020b. Note that
downloading and extracting the container image can take some time.
Run the MATLAB container using this command:
docker run -it --rm -p 5901:5901 -p 6080:6080 --shm-size=512M mathworks/matlab:r20XYz -vnc
-it runs the container in interactive
mode.
--rm deletes the container when
finished.
-p 5901:5901 and -p
6080:6080 expose port 5901 for the VNC connection and
port 6080 for the web browser connection.
--shm-size=512M sets the size of shared memory
to 512 MB, which is required for MATLAB desktop to run
correctly.
:r20XYz chooses the release version of the
MATLAB container.
-vnc starts the VNC server process for
MATLAB desktop.
To access the MATLAB desktop via a web browser, use the URL
http://hostname:6080, where hostname
is the name of the machine hosting the container. To access the container, use
the default password matlab. Alternatively, you can use the
same password to access the container via a VNC client. If you are using a cloud
service provider or if your host or client machines are protected by a firewall,
you must set up SSH tunnels between your client machine and the Docker host to access the container desktop.
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 using environment variables, see Configure Containers.