{"id":15716359,"url":"https://github.com/mathworks-ref-arch/matlab-dockerfile","last_synced_at":"2025-05-15T20:03:18.754Z","repository":{"id":35945881,"uuid":"211346419","full_name":"mathworks-ref-arch/matlab-dockerfile","owner":"mathworks-ref-arch","description":"Create a docker container that contains a MATLAB install","archived":false,"fork":false,"pushed_at":"2025-05-13T09:14:17.000Z","size":185,"stargazers_count":370,"open_issues_count":21,"forks_count":99,"subscribers_count":30,"default_branch":"main","last_synced_at":"2025-05-13T10:26:55.042Z","etag":null,"topics":["matlab","matlab-docker"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathworks-ref-arch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-09-27T15:13:26.000Z","updated_at":"2025-05-13T09:14:21.000Z","dependencies_parsed_at":"2023-01-16T09:37:55.230Z","dependency_job_id":"32dac452-b2d8-4563-ba4d-59c6277ea019","html_url":"https://github.com/mathworks-ref-arch/matlab-dockerfile","commit_stats":{"total_commits":99,"total_committers":20,"mean_commits":4.95,"dds":0.7575757575757576,"last_synced_commit":"a12591ce7bfcce82e29436e119bb0e7db94bf08c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-ref-arch%2Fmatlab-dockerfile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-ref-arch%2Fmatlab-dockerfile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-ref-arch%2Fmatlab-dockerfile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-ref-arch%2Fmatlab-dockerfile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathworks-ref-arch","download_url":"https://codeload.github.com/mathworks-ref-arch/matlab-dockerfile/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254414493,"owners_count":22067271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matlab","matlab-docker"],"created_at":"2024-10-03T21:45:14.934Z","updated_at":"2025-05-15T20:03:17.033Z","avatar_url":"https://github.com/mathworks-ref-arch.png","language":"Python","funding_links":[],"categories":["Reproducibility :gem:"],"sub_categories":["Finite Element Models"],"readme":"# Create MATLAB Container Image\n\nThis repository shows you how to build and customize a Docker\u0026reg; container for MATLAB\u0026reg; and its toolboxes, using the [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md) (`mpm`). You can use this container image as a scalable and reproducible method to deploy and test your MATLAB code.\n\nUse the [Dockerfile](Dockerfile) in this top-level repository if you want a lightweight and simple way to create a MATLAB container image. You can also download prebuilt images based on the Dockerfile from [here](https://github.com/mathworks-ref-arch/matlab-dockerfile/pkgs/container/matlab-dockerfile%2Fmatlab). \n\nFor alternative resources, see the [**alternates folder**](alternates) that contains the following Dockerfiles: \n\n* The Dockerfile in [matlab-installer](alternates/matlab-installer) uses the MATLAB installer rather than `mpm` to install MATLAB in the container. This allows you to install toolboxes that are not currently supported by mpm. Use this Dockerfile if you prefer using the MATLAB installer workflow, instead of `mpm`.\n* The Dockerfile in [building-on-matlab-docker-image](alternates/building-on-matlab-docker-image) shows you how to build on top of the [MATLAB Container Image on Docker Hub](https://hub.docker.com/r/mathworks/matlab). Use this Dockerfile if you want to install extra toolboxes on top of the `mathworks/matlab` container image. This Dockerfile contains the features of the MATLAB image on Docker Hub, allowing you to access the dockerised MATLAB through a browser, batch mode, or an interactive command prompt.\n* The Dockerfile in [non-interactive](alternates/non-interactive) allows you run MATLAB in non-interactive environments. This Dockerfile requires that you have a MATLAB batch licensing token to license MATLAB in the container. Use this Dockerfile in continuous integration and continuous delivery (CI/CD) pipelines or other automated environments where interactive licensing is not possible.\n* The Dockerfile in [matlab-container-offline-install](alternates/matlab-container-offline-install/) shows you how to build and customize a Docker container for MATLAB and its toolboxes in an offline environment. Use this Dockerfile if you must build your container image in an offline environment.\n\nFor more Docker related resources, see [More MATLAB Docker Resources](#more-matlab-docker-resources). \n\n### Requirements\n* [A running network license manager for MATLAB](https://www.mathworks.com/help/install/administer-network-licenses.html) — For more information, see [Using the Network License Manager](#use-the-network-license-manager).\n* Docker.\n\n## Build Instructions\n\n### Get Sources\n\nAccess the Dockerfile either by directly downloading this repository from GitHub\u0026reg;,\nor by cloning this repository and\nthen navigating to the appropriate folder.\n```bash\ngit clone https://github.com/mathworks-ref-arch/matlab-dockerfile.git\ncd matlab-dockerfile\n```\n\n### Build and Run Docker Image\n\nBuild container with a name and tag of your choice.\n```bash\ndocker build -t matlab:R2025a .\n```\n\nRun the container. Test the container by running an example MATLAB command, such as `ver`.\n```bash\ndocker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2025a -batch ver\n```\nThe [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile) defaults to building a container for MATLAB R2025a.\n\nThe example command `ver` displays the version number of MATLAB and other installed products. For more information, see [`ver`](https://www.mathworks.com/help/matlab/ref/ver.html). For more information on running the container, see the [Run the Container](#run-the-container) section.\n\n\u003e **Note**\n\u003e\n\u003e Use the `--init` flag in the `docker run` command to ensure that the container stops gracefully when a `docker stop` or `docker kill` command is issued.\n\u003e For more information, see these links:\n\u003e * [Reference page for `docker run`](https://docs.docker.com/reference/cli/docker/container/run/#init)\n\u003e * [Blog post on the usage of init](https://www.baeldung.com/ops/docker-init-parameter)\n\n\n## Customize the Image\n\nBy default, the [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile) installs the latest available MATLAB release without any additional toolboxes or products in the `/opt/matlab/${MATLAB_RELEASE}` folder.\n\nUse the options below to customize your build.\n\n### Customize MATLAB Release, MATLAB Product List, MATLAB Install Location, and License Server\nThe [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile) supports these Docker build-time variables:\n\n| Argument Name | Default value | Description |\n|---|---|---|\n| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | R2025a | MATLAB release to install, for example, `R2023b`.|\n| [MATLAB_PRODUCT_LIST](#build-an-image-with-a-specific-set-of-products) | MATLAB | Space-separated list of products to install, for example, `MATLAB Simulink Deep_Learning_Toolbox Fixed-Point_Designer`. For more information, see [MPM.md](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md).|\n| [MATLAB_INSTALL_LOCATION](#build-an-image-with-matlab-installed-to-a-specific-location) | /opt/matlab/R2025a | Path to install MATLAB. |\n| [LICENSE_SERVER](#build-an-image-configured-to-use-a-license-server) | *unset* | Port and hostname of the machine that is running the network license manager, using the `port@hostname` syntax. For example: `27000@MyServerName` |\n\nUse these arguments with the the `docker build` command to customize your image.\nAlternatively, you can change the default values for these arguments directly in the [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile).\n\n#### Build an Image for a Different MATLAB Release\nFor example, to build an image for MATLAB R2019b, use this command.\n```bash\ndocker build --build-arg MATLAB_RELEASE=R2019b -t matlab:R2019b .\n```\n\n#### Build an Image with a Specific Set of Products\nFor example, to build an image with MATLAB and Simulink\u0026reg;, use this command.\n```bash\ndocker build --build-arg MATLAB_PRODUCT_LIST='MATLAB Simulink' -t matlab:R2025a .\n```\n\n#### Build an Image with MATLAB Installed to a Specific Location\nFor example, to build an image with MATLAB installed at /opt/matlab, use this command.\n```bash\ndocker build --build-arg MATLAB_INSTALL_LOCATION='/opt/matlab' -t matlab:R2025a .\n```\n\n#### Build an Image Configured to Use a License Server\n\nIncluding the license server information with the `docker build` command means you do not have to pass it when running the container.\n```bash\n# Build container with the license server.\ndocker build --build-arg LICENSE_SERVER=27000@MyServerName -t matlab:R2025a .\n\n# Run the container without needing to pass license information.\ndocker run --init --rm matlab:R2025a -batch ver\n```\n\n## Use the Network License Manager\nThis container requires a network license manager to license and run MATLAB. You need either the port and hostname of the network license manager or a `network.lic` file.\n\n**Step 1**: Contact your system administrator, who can provide one of the following:\n\n* The address to your server, and the port it is running on, for example, `27000@MyServerName.example.com`\n\n* A `network.lic` file containing these lines.\n    ```bash\n    # Sample network.lic\n    SERVER MyServerName.example.com \u003coptional-mac-address\u003e 27000\n    USE_SERVER\n    ```\n\n* A `license.dat` file. Open the `license.dat` file, find the `SERVER` line, and either extract the `port@hostname`, or create a `network.lic` file by copying the `SERVER` line and adding a `USE_SERVER` line below it.\n\n    ```bash\n    # Snippet from sample license.dat\n    SERVER MyServerName.example.com \u003cmac-address\u003e 27000\n    ```\n---\n**Step 2**: Use `port@hostname` or the `network.lic` file with either the `docker build` **or** the `docker run` command.\n\nWith the `docker build` command, either:\n\n- Specify the `LICENSE_SERVER` build-arg.\n\n    ```bash\n    # Example\n    docker build -t matlab:R2025a --build-arg LICENSE_SERVER=27000@MyServerName .\n    ```\n- Use the `network.lic` file.\n    1. Place the `network.lic` file in the same folder as the Dockerfile.\n    1. Uncomment the line `COPY network.lic /opt/matlab/licenses/` in the Dockerfile.\n    1. Run the `docker build` command **without** the `LICENSE_SERVER` build-arg:\n\n    ```bash\n    # Example\n    docker build -t matlab:R2025a .\n    ```\n    \nWith the `docker run` command, use the `MLM_LICENSE_FILE` environment variable. \n\n```bash\ndocker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2025a -batch ver\n```\n\n## Run the Container\nIf you did not provide the license server information when building the image, then provide it when running the container. Set the environment variable `MLM_LICENSE_FILE` using the `-e` flag, with the  network license manager's location in the format `port@hostname`.\n\n```bash\n# Start MATLAB, print version information, and exit.\ndocker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2025a -batch ver\n```\n\nYou can run the container **without** specifying `MLM_LICENSE_FILE` if you provided the license server information when building the image, as shown in the examples below.\n\n### Run MATLAB in an Interactive Command Prompt\nTo start the container and run MATLAB in an interactive command prompt, use this command.\n```bash\ndocker run --init -it --rm matlab:R2025a\n```\n### Run MATLAB in Batch Mode\nTo start the container, run a MATLAB command, and then exit, use this command.\n```bash\n# Container runs the command RAND in MATLAB and exits.\ndocker run --init --rm matlab:R2025a -batch rand\n```\n\n### Run MATLAB with Startup Options\nTo override the default behavior of the container and run MATLAB with any set of arguments, such as `-logfile`, use this command.\n```bash\ndocker run --init -it --rm matlab:R2025a -logfile \"logfilename.log\"\n```\nTo learn more, see the documentation: [Commonly Used Startup Options](https://www.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html).\n\n\n## More MATLAB Docker Resources\n* Explore prebuilt MATLAB Docker Containers on Docker Hub: https://hub.docker.com/r/mathworks.\n    * [MATLAB Containers on Docker Hub](https://hub.docker.com/r/mathworks/matlab) hosts container images for multiple releases of MATLAB.\n    * [MATLAB Deep Learning Containers on Docker Hub](https://hub.docker.com/r/mathworks/matlab-deep-learning) hosts container images with toolboxes suitable for Deep Learning.\n* Enable additional capabilities using the [MATLAB Dependencies repository](https://github.com/mathworks-ref-arch/container-images/tree/main/matlab-deps). \nFor some workflows and toolboxes, you must specify dependencies. You must do this if you want to do these tasks:\n    * Install extended localization support for MATLAB\n    * Play media files from MATLAB\n    * Generate code from Simulink\n    * Use mex functions with gcc, g++, or gfortran\n    * Use the MATLAB Engine API for C and Fortran\u0026reg;\n    * Use the Polyspace\u0026reg; 32-bit tcc compiler\n    \n    The [MATLAB Dependencies repository](https://github.com/mathworks-ref-arch/container-images/tree/main/matlab-deps) lists Dockerfiles for various releases and platforms. To view the Dockerfile for R2025a, click [here](https://github.com/mathworks-ref-arch/container-images/blob/main/matlab-deps/r2025a/ubuntu22.04/Dockerfile).\n\n    These Dockerfiles contain commented lines with the libraries that support additional capabilities. Copy and uncomment these lines into your Dockerfile.\n\n## Help Make MATLAB Even Better\nYou can help improve MATLAB by providing user experience information on how you use MathWorks products. Your participation ensures that you are represented and helps us design better products. To opt out of this service, delete this line in the Dockerfile.\n```Dockerfile\nENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=MATLAB:DOCKERFILE:V1\n```\n\nTo learn more, see the documentation: [Help Make MATLAB Even Better - Frequently Asked Questions](https://www.mathworks.com/support/faq/user_experience_information_faq.html).\n\n## Feedback\nWe encourage you to try this repository with your environment and provide feedback. If you encounter a technical issue or have an enhancement request, create an issue [here](https://github.com/mathworks-ref-arch/matlab-dockerfile/issues).\n\n----\n\nCopyright 2021-2025 The MathWorks, Inc.\n\n----\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks-ref-arch%2Fmatlab-dockerfile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathworks-ref-arch%2Fmatlab-dockerfile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks-ref-arch%2Fmatlab-dockerfile/lists"}