Create a Custom MATLAB Container
Access MATLAB® on the cloud or in server environments by using a MATLAB container image that you can create from a Dockerfile. Use this solution when you want to create a Docker® container image with a custom MATLAB installation in a Linux® environment. Alternatively, for an out of the box MATLAB container image that you can pull from Docker Hub directly, see MATLAB Container on Docker Hub.
To create and use a custom MATLAB container, you need:
A host machine with Docker and Git™ installed.
A MATLAB license administered via a network license manager that meets the following conditions:
Linked to a MathWorks Account.
Configured for cloud use. You can identify your license type and administrator by viewing your MathWorks Account. Administrators can consult Administer Network Licenses.
You must supply the port number and DNS address of the network license manager when you build the container. Add an option of the following form to the
docker buildcommand when you create the container:Alternatively, you can use a license file to provide the location of the license manager.
If you want to use a Network Named license type with the container, you must first add the user name in the Dockerfile and then run the container with the specific user name associated with the license. For more information, see Use a Network Named License in a Container.
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 is built, so be sure to build any user name you will potentially need to use into the Dockerfile before you build the container.
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:
-u runtime flag overrides any
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
To create a Docker container image with a custom MATLAB installation follow the instructions in this GitHub® repository:
The instructions in the link explain how to build the custom MATLAB container image using a provided Dockerfile.