Main Content

创建一个CustomMATLABContainer

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, seeMATLAB Container on Docker Hub.

Requirements

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:

  • 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 thedocker buildcommand when you create the container:

    --build-arg LICENSE_SERVER=27000@MyLicenseServer
    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, seeUse 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 

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

用户<用户名>

The-uruntime flag overrides anyUSERcommand that was built into the container. You can use this to change the user of the container at runtime. For more information, see theDocker documentation.

Create Container

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.

Related Topics

External Websites