├── .github └── workflows │ ├── README-from-matlab-docker.md │ ├── README-matlab-container-offline-install.md │ ├── README-matlab-installer.md │ ├── README.md │ ├── build-test-publish.yml │ ├── from-matlab-docker-build-test.yml │ ├── matlab-container-offline-install-build-test.yml │ ├── matlab-installer-build-test.yml │ └── non-interactive-build-test.yml ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── MPM.md ├── README.md ├── SECURITY.md ├── alternates ├── building-on-matlab-docker-image │ ├── Dockerfile │ └── README.md ├── matlab-container-offline-install │ ├── Dockerfile │ ├── README.md │ └── archive.Dockerfile ├── matlab-installer │ ├── .gitignore │ ├── Dockerfile │ └── README.md └── non-interactive │ ├── Dockerfile │ ├── MATLAB-BATCH.md │ ├── README.md │ └── install │ ├── install-matlab-batch.ps1 │ └── install-matlab-batch.sh ├── mpm-input-files ├── R2017b │ └── mpm_input_r2017b.txt ├── R2018a │ └── mpm_input_r2018a.txt ├── R2018b │ └── mpm_input_r2018b.txt ├── R2019a │ └── mpm_input_r2019a.txt ├── R2019b │ └── mpm_input_r2019b.txt ├── R2020a │ └── mpm_input_r2020a.txt ├── R2020b │ └── mpm_input_r2020b.txt ├── R2021a │ └── mpm_input_r2021a.txt ├── R2021b │ └── mpm_input_r2021b.txt ├── R2022a │ └── mpm_input_r2022a.txt ├── R2022b │ └── mpm_input_r2022b.txt ├── R2023a │ └── mpm_input_r2023a.txt ├── R2023b │ └── mpm_input_r2023b.txt ├── R2024a │ └── mpm_input_r2024a.txt ├── R2024b │ └── mpm_input_r2024b.txt └── R2025a │ └── mpm_input_r2025a.txt └── tests ├── .gitignore ├── README.md ├── alternates ├── building-on-matlab-docker-image │ ├── productsTest.m │ ├── test_container.py │ ├── test_entrypoint.py │ └── test_installed_products.py ├── matlab-container-offline-install │ ├── productsTest.m │ ├── test_container.py │ └── test_installed_products.py ├── matlab-installer │ ├── .gitignore │ ├── mocks │ │ ├── matlab-install │ │ │ ├── VersionInfo.xml │ │ │ └── install │ │ └── matlab_installer_input.txt │ ├── test_failing_build.py │ └── test_mock_matlab_container.py └── non-interactive │ ├── runDisplayTest.m │ ├── test_matlabbatch.py │ └── test_matlabbatch_display.py ├── requirements.txt ├── test_container.py ├── test_running_matlab.py └── utils ├── base.py ├── dockertool.py ├── helpers.py └── mdparser.py /.github/workflows/README-from-matlab-docker.md: -------------------------------------------------------------------------------- 1 | # Build and Test the alternates/building-on-matlab-docker-image/Dockerfile 2 | 3 | > This folder is intended only for the administrators of the matlab-dockerfile repository. 4 | 5 | The workflow in this folder builds and tests the Dockerfile found in `alternates/building-on-matlab-docker-image`. 6 | 7 | ## Triggers and Scheduled Jobs 8 | 9 | The workflow is scheduled to run every Monday at 00:00. 10 | 11 | Additionally, the workflow is triggered each time you push a change in the [`Dockerfile`](../../alternates/building-on-matlab-docker-image/Dockerfile) or in the [`tests` directory](../../tests) to the repository. 12 | 13 | You can also trigger the workflow from the "Actions" tab. 14 | 15 | ## Workflow Description 16 | 17 | This workflow consists of the following steps: 18 | 19 | 1. Check-out the repository into a GitHub Actions runner. 20 | 2. Build the image from the Dockerfile. 21 | 3. Install Python and the PyPi packages listed in [`requirements.txt`](../../tests/requirements.txt). 22 | 4. Run the test files stored in [tests/alternates/building-on-matlab-docker-image](../../tests/alternates/building-on-matlab-docker-image). 23 | 24 | --- 25 | 26 | Copyright 2023-2024 The MathWorks, Inc. All rights reserved. 27 | 28 | --- 29 | -------------------------------------------------------------------------------- /.github/workflows/README-matlab-container-offline-install.md: -------------------------------------------------------------------------------- 1 | # Build and Test the alternates/matlab-container-offline-install/Dockerfile 2 | 3 | > This folder is intended only for the administrators of the matlab-dockerfile repository. 4 | 5 | The workflow in this folder builds and tests the Dockerfiles found in `alternates/matlab-container-offline-install`. 6 | 7 | ## Triggers and Scheduled Jobs 8 | 9 | The workflow is scheduled to run every Monday at 00:00. 10 | 11 | Additionally, the workflow is triggered each time you push a change in the [`archive.Dockerfile`](../../alternates/matlab-container-offline-install/archive.Dockerfile), the [`Dockerfile`](../../alternates/matlab-container-offline-install/Dockerfile) or in the [`tests` directory](../../tests/) to the repository. 12 | 13 | You can also trigger the workflow from the "Actions" tab. 14 | 15 | ## Workflow Description 16 | 17 | This workflow consists of the following steps: 18 | 19 | 1. Check-out the repository into a GitHub Actions runner. 20 | 2. Build the archive image. 21 | 3. Build the product image, in an offline environment. 22 | 4. Install Python and the PyPi packages listed in [`requirements.txt`](../../tests/requirements.txt). 23 | 5. Run the test files stored in [tests/alternates/matlab-container-offline-install](../../tests/alternates/matlab-container-offline-install). 24 | 25 | --- 26 | 27 | Copyright 2024 The MathWorks, Inc. All rights reserved. 28 | 29 | --- 30 | -------------------------------------------------------------------------------- /.github/workflows/README-matlab-installer.md: -------------------------------------------------------------------------------- 1 | # Build and Test the alternates/matlab-installer/Dockerfile 2 | 3 | > This folder is intended only for the administrators of the matlab-dockerfile repository. 4 | 5 | The workflow in this folder builds and tests the Dockerfile found in `alternates/matlab-installer` using a mocked version of the matlab-installer. 6 | 7 | ## Triggers and Scheduled Jobs 8 | 9 | The workflow is scheduled to run every Monday at 00:00. 10 | 11 | Additionally, the workflow is triggered each time you push a change in the [`Dockerfile`](../../alternates/matlab-installer/Dockerfile) or in the [`tests` directory](../../tests) to the repository. 12 | 13 | You can also trigger the workflow from the "Actions" tab. 14 | 15 | ## Workflow Description 16 | 17 | This workflow consists of the following steps: 18 | 19 | 1. Check-out the repository into a GitHub Actions runner. 20 | 2. Copy the content of [`test/mocks`](../../tests/alternates/matlab-installer/mocks) into the Docker context directory. These files are required by the [`Dockerfile`](../../alternates/matlab-installer/Dockerfile). 21 | 3. Install Python and the PyPi packages listed in [`requirements.txt`](../../tests/tests/requirements.txt). 22 | 4. Run the [test file](../../tests/alternates/matlab-installer/test_failing_build.py) to check the messages displayed when the MATLAB installer fails. 23 | 5. Build the image with the fake MATLAB installer. The real installer requires a user intervention, thus making it unsuitable for automation. 24 | 6. Run the  [test file](../../tests/alternates/matlab-installer/test_mock_matlab_container.py) to check the integration of the fake MATLAB in the Docker image. 25 | 26 | --- 27 | 28 | Copyright 2023-2024 The MathWorks, Inc. All rights reserved. 29 | 30 | --- 31 | -------------------------------------------------------------------------------- /.github/workflows/README.md: -------------------------------------------------------------------------------- 1 | # Build, Test, and Publish the Dockerfile 2 | 3 | > This folder is intended only for the administrators of the matlab-dockerfile repository. 4 | 5 | The workflow in this folder builds, tests, and publishes a Docker image in GitHub. 6 | 7 | ## Triggers and Scheduled Jobs 8 | 9 | The workflow is scheduled to run every Monday at 00:00. 10 | 11 | Additionally, the workflow is triggered each time you push a change in the [`Dockerfile`](../../Dockerfile) or in the [`tests` directory](../../tests) to the repository. 12 | 13 | You can also trigger the workflow from the "Actions" tab. 14 | 15 | ## Push the Image to the GitHub Container Registry 16 | 17 | Each time the image passes the qualification, it is pushed to the GitHub Container Registry with the name: 18 | 19 | `ghcr.io/mathworks-ref-arch/matlab-dockerfile/matlab:${matlab-release}` 20 | 21 | where `${matlab-release}` is a matlab release (e.g. `R2021a`, `R2021b`, etc..) . 22 | 23 | ## Workflow Description 24 | 25 | The workflow consists of a one-dimensional matrix of jobs. Each job builds, tests and publishes the container image for a different MATLAB release, starting from `R2020b`. To ensure that a failure in any job does not cancel other jobs, the `fail-fast` option is set to `false`. 26 | 27 | Each job consists of the following steps: 28 | 29 | 1. Check-out the repository into a GitHub Actions runner. 30 | 2. Login to ghcr.io, the GitHub Container Registry. 31 | 3. Build the image locally (set the `load` variable to `true`, as suggested in [this example](https://github.com/docker/build-push-action/blob/master/docs/advanced/test-before-push.md)). 32 | 4. Install Python and the PyPi packages listed in [`requirements.txt`](../../tests/requirements.txt). 33 | 5. Run the tests. 34 | 6. Rebuild and push the image to the GitHub Container Registry if the image passed all the tests. 35 | -------------------------------------------------------------------------------- /.github/workflows/build-test-publish.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2022-2025 The MathWorks, Inc. 2 | 3 | name: Build, Test and Publish the Dockerfile 4 | 5 | # Trigger this workflow either manually or when a new change is pushed to the 6 | # repo (except .md files) 7 | on: 8 | workflow_dispatch: 9 | push: 10 | # Trigger the workflow is the Dockerfile or any file under tests/ is modified 11 | paths: 12 | - "Dockerfile" 13 | - "tests/*" 14 | - "tests/utils/**" 15 | - ".github/workflows/build-test-publish.yml" 16 | - "!**.md" 17 | schedule: 18 | # Run at 00:00 on every Monday (1st Day of the Week) 19 | - cron: "0 0 * * 1" 20 | 21 | env: 22 | IMAGE_BASE_NAME: ghcr.io/${{ github.repository }}/matlab 23 | LICENSE_FILE_PATH: ${{ github.workspace }}/license.lic 24 | 25 | jobs: 26 | build-test-push-image: 27 | runs-on: ubuntu-latest 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | matlab-release: 32 | - R2025a 33 | - R2024b 34 | - R2024a 35 | - R2023b 36 | - R2023a 37 | - R2022b 38 | - R2022a 39 | - R2021b 40 | - R2021a 41 | - R2020b 42 | 43 | steps: 44 | - name: Checkout repo 45 | uses: actions/checkout@v4 46 | 47 | - name: Login to GitHub Container Registry 48 | uses: docker/login-action@v3 49 | with: 50 | registry: ghcr.io 51 | username: ${{ github.repository_owner }} 52 | password: ${{ secrets.GITHUB_TOKEN }} 53 | 54 | - name: Set up Docker Buildx 55 | uses: docker/setup-buildx-action@v3 56 | 57 | - name: Build image locally 58 | uses: docker/build-push-action@v5 59 | with: 60 | platforms: linux/amd64 61 | load: true 62 | build-args: | 63 | MATLAB_RELEASE=${{ matrix.matlab-release }} 64 | tags: | 65 | ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} 66 | 67 | - name: Set up Python 3 68 | uses: actions/setup-python@v5 69 | with: 70 | python-version: "3.10" 71 | 72 | - name: Install test dependencies 73 | run: | 74 | python -m pip install --upgrade pip 75 | if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi 76 | 77 | - name: Generate license file 78 | run: echo '${{ secrets.MATLAB_LICENSE_FILE_R2025A }}' > ${{ env.LICENSE_FILE_PATH }} 79 | 80 | - name: Test container 81 | env: 82 | IMAGE_NAME: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} 83 | working-directory: tests 84 | run: python -m unittest -v 85 | 86 | - name: Push the image to ghcr.io 87 | env: 88 | MATLAB_RELEASE: ${{ matrix.matlab-release }} 89 | run: | 90 | LOWERCASE_RELEASE=${MATLAB_RELEASE,,} 91 | UPPERCASE_RELEASE=${LOWERCASE_RELEASE^} 92 | docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE} 93 | docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE} 94 | docker push --all-tags ${{ env.IMAGE_BASE_NAME }} 95 | -------------------------------------------------------------------------------- /.github/workflows/from-matlab-docker-build-test.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2025 The MathWorks, Inc. 2 | 3 | name: Build and Test the "Building on MATLAB Docker Image" Dockerfile 4 | 5 | # Trigger this workflow either manually or when a new change is pushed to the 6 | # repo (except .md files) 7 | on: 8 | workflow_dispatch: 9 | push: 10 | # Trigger the workflow when the Dockerfile or any file under tests/ is modified 11 | paths: 12 | - "alternates/building-on-matlab-docker-image/Dockerfile" 13 | - "tests/alternates/building-on-matlab-docker-image/*" 14 | - "tests/utils/**" 15 | - ".github/workflows/from-matlab-docker-build-test.yml" 16 | - "!**.md" 17 | schedule: 18 | # Run at 00:00 on every Monday (1st Day of the Week) 19 | - cron: "0 0 * * 1" 20 | 21 | env: 22 | IMAGE_BASE_NAME: from-matlab-docker 23 | ALT_PATH: alternates/building-on-matlab-docker-image 24 | LICENSE_FILE_PATH: ${{ github.workspace }}/license.lic 25 | 26 | jobs: 27 | build-test-image: 28 | runs-on: ubuntu-latest 29 | strategy: 30 | fail-fast: false 31 | matrix: 32 | matlab-release: 33 | - R2025a 34 | - R2024b 35 | - R2024a 36 | - R2023b 37 | - R2023a 38 | - R2022b 39 | - R2022a 40 | 41 | steps: 42 | - name: Checkout repo 43 | uses: actions/checkout@v4 44 | 45 | - name: Set up Docker Buildx 46 | uses: docker/setup-buildx-action@v3 47 | 48 | - name: Build image locally 49 | uses: docker/build-push-action@v5 50 | with: 51 | platforms: linux/amd64 52 | context: ${{ env.ALT_PATH }} 53 | load: true 54 | build-args: | 55 | MATLAB_RELEASE=${{ matrix.matlab-release }} 56 | tags: | 57 | ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} 58 | 59 | - name: Set up Python 3 60 | uses: actions/setup-python@v5 61 | with: 62 | python-version: "3.10" 63 | 64 | - name: Install test dependencies 65 | run: | 66 | python -m pip install --upgrade pip 67 | if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi 68 | 69 | - name: Generate license file 70 | run: echo '${{ secrets.MATLAB_LICENSE_FILE_R2025A }}' > ${{ env.LICENSE_FILE_PATH }} 71 | 72 | - name: Test container 73 | working-directory: tests 74 | env: 75 | IMAGE_NAME: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} 76 | run: python -m unittest -v ${{ env.ALT_PATH }}/*.py 77 | -------------------------------------------------------------------------------- /.github/workflows/matlab-container-offline-install-build-test.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2024-2025 The MathWorks, Inc. 2 | 3 | name: Build and Test the "MATLAB Container Offline Install" Dockerfiles 4 | 5 | # Trigger this workflow either manually or when a new change is pushed to the 6 | # repo (except .md files) 7 | on: 8 | workflow_dispatch: 9 | push: 10 | # Trigger the workflow when the Dockerfile or any file under tests/ is modified 11 | paths: 12 | - "alternates/matlab-container-offline-install/archive.Dockerfile" 13 | - "alternates/matlab-container-offline-install/Dockerfile" 14 | - "tests/alternates/matlab-container-offline-install/*" 15 | - "tests/utils/**" 16 | - ".github/workflows/matlab-container-offline-install-build-test.yml" 17 | - "!**.md" 18 | schedule: 19 | # Run at 00:00 on every Monday (1st Day of the Week) 20 | - cron: "0 0 * * 1" 21 | 22 | env: 23 | ARCHIVE_BASE_NAME: mpm-archive 24 | IMAGE_BASE_NAME: matlab 25 | ALT_PATH: alternates/matlab-container-offline-install 26 | MATLAB_PRODUCT_LIST: "MATLAB Symbolic_Math_Toolbox Deep_Learning_Toolbox_Model_for_ResNet-50_Network" 27 | LICENSE_FILE_PATH: ${{ github.workspace }}/license.lic 28 | 29 | jobs: 30 | build-test-image: 31 | runs-on: ubuntu-latest 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | matlab-release: 36 | - R2025a 37 | - R2024b 38 | - R2024a 39 | - R2023b 40 | - R2023a 41 | - R2022b 42 | - R2022a 43 | - R2021b 44 | - R2021a 45 | - R2020b 46 | 47 | steps: 48 | - name: Checkout repo 49 | uses: actions/checkout@v4 50 | 51 | - name: Set up Docker Buildx 52 | uses: docker/setup-buildx-action@v3 53 | with: 54 | driver: docker 55 | 56 | - name: Build archive image 57 | uses: docker/build-push-action@v5 58 | with: 59 | platforms: linux/amd64 60 | context: ${{ env.ALT_PATH }} 61 | file: ${{ env.ALT_PATH }}/archive.Dockerfile 62 | load: true 63 | build-args: | 64 | MATLAB_RELEASE=${{ matrix.matlab-release }} 65 | MATLAB_PRODUCT_LIST=${{ env.MATLAB_PRODUCT_LIST }} 66 | tags: | 67 | ${{ env.ARCHIVE_BASE_NAME }}:${{ matrix.matlab-release }} 68 | 69 | - name: Build final image offline 70 | uses: docker/build-push-action@v5 71 | with: 72 | platforms: linux/amd64 73 | context: ${{ env.ALT_PATH }} 74 | load: true 75 | network: none 76 | build-args: | 77 | MATLAB_RELEASE=${{ matrix.matlab-release }} 78 | MATLAB_PRODUCT_LIST=${{ env.MATLAB_PRODUCT_LIST }} 79 | ARCHIVE_BASE_IMAGE=${{ env.ARCHIVE_BASE_NAME }}:${{ matrix.matlab-release }} 80 | tags: | 81 | ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} 82 | 83 | - name: Set up Python 3 84 | uses: actions/setup-python@v5 85 | with: 86 | python-version: "3.10" 87 | 88 | - name: Install test dependencies 89 | run: | 90 | python -m pip install --upgrade pip 91 | if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi 92 | 93 | - name: Generate license file 94 | run: echo '${{ secrets.MATLAB_LICENSE_FILE_R2025A }}' > ${{ env.LICENSE_FILE_PATH }} 95 | 96 | - name: Test container 97 | working-directory: tests 98 | env: 99 | IMAGE_NAME: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} 100 | run: python -m unittest -v ${{ env.ALT_PATH }}/*.py 101 | -------------------------------------------------------------------------------- /.github/workflows/matlab-installer-build-test.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2025 The MathWorks, Inc. 2 | 3 | name: Build and Test the "MATLAB installer" Dockerfile 4 | 5 | # Trigger this workflow either manually or when a new change is pushed to the 6 | # repo (except .md files) 7 | on: 8 | workflow_dispatch: 9 | push: 10 | # Trigger the workflow when the Dockerfile or any file under tests/ is modified 11 | paths: 12 | - "alternates/matlab-installer/Dockerfile" 13 | - "tests/alternates/matlab-installer/*" 14 | - "tests/utils/**" 15 | - ".github/workflows/matlab-installer-build-test.yml" 16 | - "!**.md" 17 | schedule: 18 | # Run at 00:00 on every Monday (1st Day of the Week) 19 | - cron: "0 0 * * 1" 20 | 21 | env: 22 | IMAGE_BASE_NAME: matlab-installer 23 | ALT_PATH: alternates/matlab-installer 24 | 25 | jobs: 26 | build-test-image: 27 | runs-on: ubuntu-latest 28 | defaults: 29 | run: 30 | shell: bash 31 | strategy: 32 | fail-fast: false 33 | matrix: 34 | matlab-release: 35 | - R2025a 36 | - R2024b 37 | - R2024a 38 | - R2023b 39 | - R2023a 40 | - R2022b 41 | - R2022a 42 | - R2021b 43 | - R2021a 44 | - R2020b 45 | 46 | steps: 47 | - name: Checkout repo 48 | uses: actions/checkout@v4 49 | 50 | - name: Move matlab-install mock to right location 51 | run: | 52 | cp -r tests/${{ env.ALT_PATH }}/mocks/matlab-install ./${{ env.ALT_PATH }} 53 | cp tests/${{ env.ALT_PATH }}/mocks/matlab_installer_input.txt ./${{ env.ALT_PATH }} 54 | 55 | - name: Set up Python 3 56 | uses: actions/setup-python@v5 57 | with: 58 | python-version: "3.10" 59 | 60 | - name: Install test dependencies 61 | run: | 62 | python -m pip install --upgrade pip 63 | if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi 64 | 65 | - name: Run negative tests 66 | working-directory: tests 67 | run: python -m unittest ${{ env.ALT_PATH }}/test_failing_build.py 68 | 69 | - name: Set up Docker Buildx 70 | uses: docker/setup-buildx-action@v3 71 | 72 | - name: Build image locally 73 | uses: docker/build-push-action@v5 74 | with: 75 | platforms: linux/amd64 76 | context: ${{ env.ALT_PATH }} 77 | load: true 78 | build-args: MATLAB_RELEASE=${{ matrix.matlab-release }} 79 | tags: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} 80 | 81 | - name: Test container 82 | working-directory: tests 83 | env: 84 | IMAGE_NAME: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} 85 | run: python -m unittest -v ${{ env.ALT_PATH }}/*.py 86 | -------------------------------------------------------------------------------- /.github/workflows/non-interactive-build-test.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2024-2025 The MathWorks, Inc. 2 | 3 | name: Build and Test the "Non-Interactive" Dockerfile 4 | 5 | # Trigger this workflow either manually or when a new change is pushed to the 6 | # repo (except .md files) 7 | on: 8 | workflow_dispatch: 9 | push: 10 | # Trigger the workflow when the Dockerfile or any file under tests/ is modified 11 | paths: 12 | - "alternates/non-interactive/Dockerfile" 13 | - "tests/alternates/non-interactive/*" 14 | - "tests/utils/**" 15 | - ".github/workflows/non-interactive-build-test.yml" 16 | - "!**.md" 17 | schedule: 18 | # Run at 00:00 on every Monday (1st Day of the Week) 19 | - cron: "0 0 * * 1" 20 | 21 | env: 22 | IMAGE_BASE_NAME: ghcr.io/${{ github.repository }}/matlab-non-interactive 23 | ALT_PATH: alternates/non-interactive 24 | 25 | jobs: 26 | build-test-image: 27 | runs-on: ubuntu-latest 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | matlab-release: 32 | - R2025a 33 | - R2024b 34 | - R2024a 35 | - R2023b 36 | - R2023a 37 | - R2022b 38 | - R2022a 39 | - R2021b 40 | - R2021a 41 | - R2020b 42 | 43 | steps: 44 | - name: Checkout repo 45 | uses: actions/checkout@v4 46 | 47 | - name: Login to GitHub Container Registry 48 | uses: docker/login-action@v3 49 | with: 50 | registry: ghcr.io 51 | username: ${{ github.repository_owner }} 52 | password: ${{ secrets.GITHUB_TOKEN }} 53 | 54 | - name: Set up Docker Buildx 55 | uses: docker/setup-buildx-action@v3 56 | 57 | - name: Build image locally 58 | uses: docker/build-push-action@v5 59 | with: 60 | platforms: linux/amd64 61 | context: ${{ env.ALT_PATH }} 62 | load: true 63 | build-args: | 64 | MATLAB_RELEASE=${{ matrix.matlab-release }} 65 | tags: | 66 | ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} 67 | 68 | - name: Set up Python 3 69 | uses: actions/setup-python@v5 70 | with: 71 | python-version: "3.10" 72 | 73 | - name: Install test dependencies 74 | run: | 75 | python -m pip install --upgrade pip 76 | if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi 77 | 78 | - name: Test container 79 | working-directory: tests 80 | env: 81 | IMAGE_NAME: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} 82 | BATCH_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN_EXPIRES_03_2026 }} 83 | run: python -m unittest -v ${{ env.ALT_PATH }}/*.py 84 | 85 | - name: Push the image to ghcr.io 86 | env: 87 | MATLAB_RELEASE: ${{ matrix.matlab-release }} 88 | run: | 89 | LOWERCASE_RELEASE=${MATLAB_RELEASE,,} 90 | UPPERCASE_RELEASE=${LOWERCASE_RELEASE^} 91 | docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE} 92 | docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE} 93 | docker push --all-tags ${{ env.IMAGE_BASE_NAME }} 94 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright 2019 - 2022 The MathWorks, Inc. 2 | .vscode/ -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2019-2025 The MathWorks, Inc. 2 | # This Dockerfile allows you to build a Docker® image with MATLAB® installed using the MATLAB Package 3 | # Manager. Use the optional build arguments to customize the version of MATLAB, list of products to 4 | # install, and the location at which to install MATLAB. 5 | 6 | # Here is an example docker build command with the optional build arguments. 7 | # docker build --build-arg MATLAB_RELEASE=R2025a 8 | # --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox" 9 | # --build-arg MATLAB_INSTALL_LOCATION="/opt/matlab/R2025a" 10 | # --build-arg LICENSE_SERVER=12345@hostname.com 11 | # -t my_matlab_image_name . 12 | 13 | # To specify which MATLAB release to install in the container, edit the value of the MATLAB_RELEASE argument. 14 | # Use uppercase to specify the release, for example: ARG MATLAB_RELEASE=R2021b 15 | ARG MATLAB_RELEASE=R2025a 16 | 17 | # Specify the list of products to install into MATLAB. 18 | ARG MATLAB_PRODUCT_LIST="MATLAB" 19 | 20 | # Specify MATLAB Install Location. 21 | ARG MATLAB_INSTALL_LOCATION="/opt/matlab/${MATLAB_RELEASE}" 22 | 23 | # Specify license server information using the format: port@hostname 24 | ARG LICENSE_SERVER 25 | 26 | # When you start the build stage, this Dockerfile by default uses the Ubuntu-based matlab-deps image. 27 | # To check the available matlab-deps images, see: https://hub.docker.com/r/mathworks/matlab-deps 28 | FROM mathworks/matlab-deps:${MATLAB_RELEASE} 29 | 30 | # Declare build arguments to use at the current build stage. 31 | ARG MATLAB_RELEASE 32 | ARG MATLAB_PRODUCT_LIST 33 | ARG MATLAB_INSTALL_LOCATION 34 | ARG LICENSE_SERVER 35 | 36 | # Install mpm dependencies. 37 | RUN export DEBIAN_FRONTEND=noninteractive \ 38 | && apt-get update \ 39 | && apt-get install --no-install-recommends --yes \ 40 | wget \ 41 | ca-certificates \ 42 | && apt-get clean \ 43 | && apt-get autoremove \ 44 | && rm -rf /var/lib/apt/lists/* 45 | 46 | # Add "matlab" user and grant sudo permission. 47 | RUN adduser --shell /bin/bash --disabled-password --gecos "" matlab \ 48 | && echo "matlab ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/matlab \ 49 | && chmod 0440 /etc/sudoers.d/matlab 50 | 51 | # Set user and work directory. 52 | USER matlab 53 | WORKDIR /home/matlab 54 | 55 | # Run mpm to install MATLAB in the target location and delete the mpm installation afterwards. 56 | # If mpm fails to install successfully, then print the logfile in the terminal, otherwise clean up. 57 | # Pass in $HOME variable to install support packages into the user's HOME folder. 58 | RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \ 59 | && chmod +x mpm \ 60 | && sudo HOME=${HOME} ./mpm install \ 61 | --release=${MATLAB_RELEASE} \ 62 | --destination=${MATLAB_INSTALL_LOCATION} \ 63 | --products ${MATLAB_PRODUCT_LIST} \ 64 | || (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \ 65 | && sudo rm -rf mpm /tmp/mathworks_root.log \ 66 | && sudo ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab 67 | 68 | # Note: Uncomment one of the following two ways to configure the license server. 69 | 70 | # Option 1. Specify the host and port of the machine that serves the network licenses 71 | # if you want to store the license information in an environment variable. This 72 | # is the preferred option. You can either use a build variable, like this: 73 | # --build-arg LICENSE_SERVER=27000@MyServerName or you can specify the license server 74 | # directly using: ENV MLM_LICENSE_FILE=27000@flexlm-server-name 75 | ENV MLM_LICENSE_FILE=$LICENSE_SERVER 76 | 77 | # Option 2. Alternatively, you can put a license file into the container. 78 | # Enter the details of the license server in this file and uncomment the following line. 79 | # COPY network.lic ${MATLAB_INSTALL_LOCATION}/licenses/ 80 | 81 | # The following environment variables allow MathWorks to understand how this MathWorks 82 | # product (MATLAB Dockerfile) is being used. This information helps us make MATLAB even better. 83 | # Your content, and information about the content within your files, is not shared with MathWorks. 84 | # To opt out of this service, delete the environment variables defined in the following line. 85 | # To learn more, see the Help Make MATLAB Even Better section in the accompanying README: 86 | # https://github.com/mathworks-ref-arch/matlab-dockerfile#help-make-matlab-even-better 87 | ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=MATLAB:DOCKERFILE:V1 88 | 89 | ENTRYPOINT ["matlab"] 90 | CMD [""] -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MATHWORKS CLOUD REFERENCE ARCHITECTURE LICENSE 2 | 3 | The files in this GitHub repository refer to commercial software products and services, virtual machine images, and related materials of The MathWorks, Inc. (“MathWorks Programs”). MathWorks Programs are separately licensed under the MathWorks Software License Agreement, available in the desktop installation of the MathWorks Programs or in the virtual machine image. The files in this GitHub repository may also refer to third-party software licensed under separate terms provided by such third parties. 4 | 5 | The following license terms apply only to the files in this GitHub repository, including files in this folder and its subfolders, and do not apply to MathWorks Programs. References to “software” and “code” in the following license terms refer to the files in this GitHub repository. 6 | 7 | Copyright 2020, The MathWorks, Inc. 8 | 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 12 | 13 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 14 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 15 | 3. In all cases, the software is, and all modifications and derivatives of the software shall be, licensed to you solely for use in conjunction with MathWorks products and service offerings. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 | -------------------------------------------------------------------------------- /MPM.md: -------------------------------------------------------------------------------- 1 | # MATLAB Package Manager 2 | 3 | Use MATLAB® Package Manager (`mpm`) to install MATLAB, Simulink®, and other MathWorks® products or support packages from the operating system command line. 4 | 5 | To get `mpm` for Linux, Windows, or macOS, see [Get MATLAB Package Manager](https://www.mathworks.com/help/install/ug/get-mpm-os-command-line.html). 6 | 7 | For information on using `mpm`, see these command reference pages: 8 | | Command | Description | 9 | | ------ | ----------- | 10 | [`mpm install`](https://www.mathworks.com/help/install/ug/mpminstall.html) | Install products and support packages 11 | [`mpm download`](https://www.mathworks.com/help/install/ug/mpmdownload.html) | Download products and support packages 12 | [`mpm install-doc`](https://www.mathworks.com/help/install/ug/mpminstalldoc.html) | Install documentation 13 | [`mpm --help`](https://www.mathworks.com/help/install/ug/mpmhelp.html) | Get help using MATLAB Package Manager 14 | [`mpm --version`](https://www.mathworks.com/help/install/ug/mpmversion.html) | Get MATLAB Package Manager version information 15 | 16 | For information on using `mpm` in the MATLAB Dockerfile, see [Create a MATLAB Container Image](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/README.md). 17 | 18 | ## Feedback and Support 19 | 20 | If you encounter a technical issue or have an enhancement request, create an issue [here](https://github.com/mathworks-ref-arch/matlab-dockerfile/issues). 21 | 22 | ## Changelog 23 | 24 | ### 2025.1 - April 2, 2025 25 | - **Added**: Use the `--no-deps` option of `mpm download` to download only the specified products and omit product dependencies. Specify this option when all required dependencies have already been downloaded or are currently installed. 26 | 27 | ### 2024.4 - December 11, 2024 28 | - **Added**: Support for installing IEC Certification Kit, DO Qualification Kit, and Simulink Code Inspector from source files downloaded using the interactive product installer, as described in [Download Products Without Installing](https://www.mathworks.com/help/install/ug/download-without-installing.html). You must have a license for these products to download them. 29 | - **Added**: When you download products using `mpm download`, the downloaded folder now includes platform-specific versions of `mpm` that you can use to install products on target computers. 30 | 31 | ### 2024.3 - October 2, 2024 32 | - **Added**: Use the `--inputfile` option of `mpm download` to download products by specifying options in an input file. Using this file, you can select the products and support packages you want to download without having to enter them at the command line. 33 | - **Added**: Use the `--platforms` option of `mpm download` to download products for multiple platforms. Previously, `mpm download` downloaded products only for the platform of the computer performing the download. 34 | 35 | ### 2024.2.2 - August 14, 2024 36 | - **Security:** Patched CVE-2023-45853. 37 | 38 | ### 2024.2.1 - July 24, 2024 39 | - **Fixed:** Resolved an issue that causes `mpm` to fail on some Linux distributions. 40 | 41 | ### 2024.2 - July 17, 2024 42 | - **Added**: Use `mpm download` to download products and support packages without installing them. 43 | - **Added**: Install support packages that were downloaded using `mpm download`. 44 | - **Added**: Support for installing IEC Certification Kit, DO Qualification Kit, and Simulink Code Inspector from a mounted ISO image. For an example, see [Install Products from Mounted ISO Image](https://www.mathworks.com/help/install/ug/mpminstall.html#mw_3a3793a5-4576-464b-adf9-24c714709e6c). 45 | - **Changed**: `mpm` now omits installing products that are already installed instead of issuing an error. 46 | 47 | ### 2024.1.1 - March 27, 2024 48 | - **Added:** Specify the `--no-jre` option that allows you to skip installing the default Java Runtime Environment (JRE) used by MATLAB and set a custom JRE instead. For information on which JREs are supported, see [Versions of OpenJDK Compatible with MATLAB by Release](https://www.mathworks.com/support/requirements/openjdk.html) on the MathWorks website. 49 | - **Changed:** Versioning changed from YYYY.MM.MINOR.MICRO to YYYY.MINOR.MICRO [Calendar Versioning](https://calver.org/). 50 | 51 | ### 2023.12.1 - December 14, 2023 52 | - **Added:** Support for Windows 53 | - **Added:** Support for macOS 54 | 55 | ### 2023.10.0.1 - October 26, 2023 56 | - **Added:** Install hardware and software support packages. 57 | - **Added:** Install required products automatically. For example, if you specify `--product Simulink`, then `mpm` installs both Simulink and the required product MATLAB. 58 | - **Added:** Install products by specifying options in an input file. 59 | 60 | ### 2023.9 - September 13, 2023 61 | 62 | - **Fixed:** Resolved an issue that prevented installation of R2023b. 63 | 64 | ### 2023.3 - March 23, 2023 65 | 66 | - **Added:** Specify the `--no-gpu` option to prevent installation of GPU libraries when you install Parallel Computing Toolbox. 67 | - **Changed:** Versioning changed from [Semantic Versioning](https://semver.org/) to [Calendar Versioning](https://calver.org/). 68 | 69 | ### 0.8.0 - December 17, 2022 70 | 71 | - **Added:** Install a specific MATLAB update level. For example, to download MATLAB R2022b Update 2, specify the `--release` option as `R2022bU2`. 72 | 73 | ### 0.7.0 - November 4, 2022 74 | 75 | - **Added:** Foundation changes to support upcoming features. 76 | - **Fixed:** Improved parsing for `--release` option. 77 | 78 | ### 0.6.0 - July 14, 2022 79 | 80 | - **Added:** By default, MATLAB documentation and examples are not installed with MATLAB. 81 | - **Added:** Use the `--doc` option to include documentation and examples with the MATLAB installation. 82 | - **Added:** The `mpm` command now observes `TMPDIR` environment variable. 83 | - **Fixed:** The `mpm` command no longer crashes at run time on RHEL7/UBI7. 84 | - **Fixed:** Changed dropped packet behavior to improve download resilience in adverse network conditions. 85 | - **Fixed:** Improved error message for installing into a MATLAB instance that does not match the specified release. 86 | 87 | ### 0.5.1 - February 14, 2022 88 | 89 | - **Fixed:** Installing a toolbox into an existing MATLAB instance at any update level that is not the latest update level for that release no longer results in the installed products throwing an error when invoked. 90 | 91 | ### 0.5.0 - December 6, 2021 92 | 93 | - **Added:** Initial release 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Create MATLAB Container Image 2 | 3 | This repository shows you how to build and customize a Docker® container for MATLAB® 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. 4 | 5 | Use 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). 6 | 7 | For alternative resources, see the [**alternates folder**](alternates) that contains the following Dockerfiles: 8 | 9 | * 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`. 10 | * 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. 11 | * 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. 12 | * 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. 13 | 14 | For more Docker related resources, see [More MATLAB Docker Resources](#more-matlab-docker-resources). 15 | 16 | ### Requirements 17 | * [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). 18 | * Docker. 19 | 20 | ## Build Instructions 21 | 22 | ### Get Sources 23 | 24 | Access the Dockerfile either by directly downloading this repository from GitHub®, 25 | or by cloning this repository and 26 | then navigating to the appropriate folder. 27 | ```bash 28 | git clone https://github.com/mathworks-ref-arch/matlab-dockerfile.git 29 | cd matlab-dockerfile 30 | ``` 31 | 32 | ### Build and Run Docker Image 33 | 34 | Build container with a name and tag of your choice. 35 | ```bash 36 | docker build -t matlab:R2025a . 37 | ``` 38 | 39 | Run the container. Test the container by running an example MATLAB command, such as `ver`. 40 | ```bash 41 | docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2025a -batch ver 42 | ``` 43 | The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile) defaults to building a container for MATLAB R2025a. 44 | 45 | The 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. 46 | 47 | > **Note** 48 | > 49 | > 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. 50 | > For more information, see these links: 51 | > * [Reference page for `docker run`](https://docs.docker.com/reference/cli/docker/container/run/#init) 52 | > * [Blog post on the usage of init](https://www.baeldung.com/ops/docker-init-parameter) 53 | 54 | 55 | ## Customize the Image 56 | 57 | By 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. 58 | 59 | Use the options below to customize your build. 60 | 61 | ### Customize MATLAB Release, MATLAB Product List, MATLAB Install Location, and License Server 62 | The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile) supports these Docker build-time variables: 63 | 64 | | Argument Name | Default value | Description | 65 | |---|---|---| 66 | | [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | R2025a | MATLAB release to install, for example, `R2023b`.| 67 | | [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).| 68 | | [MATLAB_INSTALL_LOCATION](#build-an-image-with-matlab-installed-to-a-specific-location) | /opt/matlab/R2025a | Path to install MATLAB. | 69 | | [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` | 70 | 71 | Use these arguments with the the `docker build` command to customize your image. 72 | Alternatively, you can change the default values for these arguments directly in the [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile). 73 | 74 | #### Build an Image for a Different MATLAB Release 75 | For example, to build an image for MATLAB R2019b, use this command. 76 | ```bash 77 | docker build --build-arg MATLAB_RELEASE=R2019b -t matlab:R2019b . 78 | ``` 79 | 80 | #### Build an Image with a Specific Set of Products 81 | For example, to build an image with MATLAB and Simulink®, use this command. 82 | ```bash 83 | docker build --build-arg MATLAB_PRODUCT_LIST='MATLAB Simulink' -t matlab:R2025a . 84 | ``` 85 | 86 | #### Build an Image with MATLAB Installed to a Specific Location 87 | For example, to build an image with MATLAB installed at /opt/matlab, use this command. 88 | ```bash 89 | docker build --build-arg MATLAB_INSTALL_LOCATION='/opt/matlab' -t matlab:R2025a . 90 | ``` 91 | 92 | #### Build an Image Configured to Use a License Server 93 | 94 | Including the license server information with the `docker build` command means you do not have to pass it when running the container. 95 | ```bash 96 | # Build container with the license server. 97 | docker build --build-arg LICENSE_SERVER=27000@MyServerName -t matlab:R2025a . 98 | 99 | # Run the container without needing to pass license information. 100 | docker run --init --rm matlab:R2025a -batch ver 101 | ``` 102 | 103 | ## Use the Network License Manager 104 | This 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. 105 | 106 | **Step 1**: Contact your system administrator, who can provide one of the following: 107 | 108 | * The address to your server, and the port it is running on, for example, `27000@MyServerName.example.com` 109 | 110 | * A `network.lic` file containing these lines. 111 | ```bash 112 | # Sample network.lic 113 | SERVER MyServerName.example.com 27000 114 | USE_SERVER 115 | ``` 116 | 117 | * 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. 118 | 119 | ```bash 120 | # Snippet from sample license.dat 121 | SERVER MyServerName.example.com 27000 122 | ``` 123 | --- 124 | **Step 2**: Use `port@hostname` or the `network.lic` file with either the `docker build` **or** the `docker run` command. 125 | 126 | With the `docker build` command, either: 127 | 128 | - Specify the `LICENSE_SERVER` build-arg. 129 | 130 | ```bash 131 | # Example 132 | docker build -t matlab:R2025a --build-arg LICENSE_SERVER=27000@MyServerName . 133 | ``` 134 | - Use the `network.lic` file. 135 | 1. Place the `network.lic` file in the same folder as the Dockerfile. 136 | 1. Uncomment the line `COPY network.lic /opt/matlab/licenses/` in the Dockerfile. 137 | 1. Run the `docker build` command **without** the `LICENSE_SERVER` build-arg: 138 | 139 | ```bash 140 | # Example 141 | docker build -t matlab:R2025a . 142 | ``` 143 | 144 | With the `docker run` command, use the `MLM_LICENSE_FILE` environment variable. 145 | 146 | ```bash 147 | docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2025a -batch ver 148 | ``` 149 | 150 | ## Run the Container 151 | If 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`. 152 | 153 | ```bash 154 | # Start MATLAB, print version information, and exit. 155 | docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2025a -batch ver 156 | ``` 157 | 158 | You 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. 159 | 160 | ### Run MATLAB in an Interactive Command Prompt 161 | To start the container and run MATLAB in an interactive command prompt, use this command. 162 | ```bash 163 | docker run --init -it --rm matlab:R2025a 164 | ``` 165 | ### Run MATLAB in Batch Mode 166 | To start the container, run a MATLAB command, and then exit, use this command. 167 | ```bash 168 | # Container runs the command RAND in MATLAB and exits. 169 | docker run --init --rm matlab:R2025a -batch rand 170 | ``` 171 | 172 | ### Run MATLAB with Startup Options 173 | To override the default behavior of the container and run MATLAB with any set of arguments, such as `-logfile`, use this command. 174 | ```bash 175 | docker run --init -it --rm matlab:R2025a -logfile "logfilename.log" 176 | ``` 177 | To learn more, see the documentation: [Commonly Used Startup Options](https://www.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html). 178 | 179 | 180 | ## More MATLAB Docker Resources 181 | * Explore prebuilt MATLAB Docker Containers on Docker Hub: https://hub.docker.com/r/mathworks. 182 | * [MATLAB Containers on Docker Hub](https://hub.docker.com/r/mathworks/matlab) hosts container images for multiple releases of MATLAB. 183 | * [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. 184 | * Enable additional capabilities using the [MATLAB Dependencies repository](https://github.com/mathworks-ref-arch/container-images/tree/main/matlab-deps). 185 | For some workflows and toolboxes, you must specify dependencies. You must do this if you want to do these tasks: 186 | * Install extended localization support for MATLAB 187 | * Play media files from MATLAB 188 | * Generate code from Simulink 189 | * Use mex functions with gcc, g++, or gfortran 190 | * Use the MATLAB Engine API for C and Fortran® 191 | * Use the Polyspace® 32-bit tcc compiler 192 | 193 | 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). 194 | 195 | These Dockerfiles contain commented lines with the libraries that support additional capabilities. Copy and uncomment these lines into your Dockerfile. 196 | 197 | ## Help Make MATLAB Even Better 198 | You 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. 199 | ```Dockerfile 200 | ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=MATLAB:DOCKERFILE:V1 201 | ``` 202 | 203 | To learn more, see the documentation: [Help Make MATLAB Even Better - Frequently Asked Questions](https://www.mathworks.com/support/faq/user_experience_information_faq.html). 204 | 205 | ## Feedback 206 | We 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). 207 | 208 | ---- 209 | 210 | Copyright 2021-2025 The MathWorks, Inc. 211 | 212 | ---- 213 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | Reporting Security Vulnerabilities 2 | ================================== 3 | If you believe you have discovered a security vulnerability, please report it to 4 | security@mathworks.com instead of GitHub. Please see 5 | [MathWorks Vulnerability Disclosure Policy for Security Researchers](https://www.mathworks.com/company/aboutus/policies_statements/vulnerability-disclosure-policy.html) 6 | for additional information. 7 | -------------------------------------------------------------------------------- /alternates/building-on-matlab-docker-image/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2025 The MathWorks, Inc. 2 | 3 | # To specify which MATLAB release to install in the container, edit the value of the MATLAB_RELEASE argument. 4 | # Use uppercase to specify the release, for example: ARG MATLAB_RELEASE=R2021b 5 | ARG MATLAB_RELEASE=R2025a 6 | 7 | # Specify the extra products to install into the image. These products can either be toolboxes or support packages. 8 | ARG ADDITIONAL_PRODUCTS="Symbolic_Math_Toolbox Deep_Learning_Toolbox_Model_for_ResNet-50_Network" 9 | 10 | # This Dockerfile builds on the Ubuntu-based mathworks/matlab image. 11 | # To check the available matlab images, see: https://hub.docker.com/r/mathworks/matlab 12 | FROM mathworks/matlab:$MATLAB_RELEASE 13 | 14 | # Declare the global argument to use at the current build stage 15 | ARG MATLAB_RELEASE 16 | ARG ADDITIONAL_PRODUCTS 17 | 18 | # By default, the MATLAB container runs as user "matlab". To install mpm dependencies, switch to root. 19 | USER root 20 | 21 | # Install mpm dependencies 22 | RUN export DEBIAN_FRONTEND=noninteractive \ 23 | && apt-get update \ 24 | && apt-get install --no-install-recommends --yes \ 25 | wget \ 26 | ca-certificates \ 27 | && apt-get clean \ 28 | && apt-get autoremove \ 29 | && rm -rf /var/lib/apt/lists/* 30 | 31 | # Run mpm to install MathWorks products into the existing MATLAB installation directory, 32 | # and delete the mpm installation afterwards. 33 | # Modify it by setting the ADDITIONAL_PRODUCTS defined above, 34 | # e.g. ADDITIONAL_PRODUCTS="Statistics_and_Machine_Learning_Toolbox Parallel_Computing_Toolbox MATLAB_Coder". 35 | # If mpm fails to install successfully then output the logfile to the terminal, otherwise cleanup. 36 | 37 | # Switch to user matlab, and pass in $HOME variable to mpm, 38 | # so that mpm can set the correct root folder for the support packages. 39 | WORKDIR /tmp 40 | USER matlab 41 | RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \ 42 | && chmod +x mpm \ 43 | && EXISTING_MATLAB_LOCATION=$(dirname $(dirname $(readlink -f $(which matlab)))) \ 44 | && sudo HOME=${HOME} ./mpm install \ 45 | --destination=${EXISTING_MATLAB_LOCATION} \ 46 | --release=${MATLAB_RELEASE} \ 47 | --products ${ADDITIONAL_PRODUCTS} \ 48 | || (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \ 49 | && sudo rm -rf mpm /tmp/mathworks_root.log 50 | 51 | # When running the container a license file can be mounted, 52 | # or a license server can be provided as an environment variable. 53 | # For more information, see https://hub.docker.com/r/mathworks/matlab 54 | 55 | # Alternatively, you can provide a license server to use 56 | # with the docker image while building the image. 57 | # Specify the host and port of the machine that serves the network licenses 58 | # if you want to bind in the license info as an environment variable. 59 | # You can also build with something like --build-arg LICENSE_SERVER=27000@MyServerName, 60 | # in which case you should uncomment the following two lines. 61 | # If these lines are uncommented, $LICENSE_SERVER must be a valid license 62 | # server or browser mode will not start successfully. 63 | # ARG LICENSE_SERVER 64 | # ENV MLM_LICENSE_FILE=$LICENSE_SERVER 65 | 66 | # The following environment variables allow MathWorks to understand how this MathWorks 67 | # product is being used. This information helps us make MATLAB even better. 68 | # Your content, and information about the content within your files, is not shared with MathWorks. 69 | # To opt out of this service, delete the environment variables defined in the following line. 70 | # See the Help Make MATLAB Even Better section in the accompanying README to learn more: 71 | # https://github.com/mathworks-ref-arch/matlab-dockerfile#help-make-matlab-even-better 72 | ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=$MW_CONTEXT_TAGS,MATLAB:TOOLBOXES:DOCKERFILE:V1 73 | 74 | WORKDIR /home/matlab 75 | # Inherit ENTRYPOINT and CMD from base image. 76 | -------------------------------------------------------------------------------- /alternates/building-on-matlab-docker-image/README.md: -------------------------------------------------------------------------------- 1 | # Building on MATLAB Docker Image 2 | 3 | The Dockerfile in this subfolder builds on the [MATLAB Container Image on Docker Hub](https://hub.docker.com/r/mathworks/matlab) 4 | by installing MATLAB® toolboxes and support packages using [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md) (`mpm`). 5 | 6 | Use the Dockerfile as an example of how to build a custom image that contains the features of the MATLAB image on Docker® Hub. 7 | These features include accessing the dockerized MATLAB through a browser, batch mode, or an interactive command prompt. 8 | For details of the features in the image, see [MATLAB Container Image on Docker Hub](https://hub.docker.com/r/mathworks/matlab). 9 | 10 | ### Requirements 11 | * Docker 12 | 13 | ## Build Instructions 14 | 15 | ### Get the Dockerfile 16 | 17 | Access the Dockerfile either by directly downloading this repository from GitHub®, 18 | or by cloning this repository and 19 | then navigating to the appropriate subfolder. 20 | ```bash 21 | git clone https://github.com/mathworks-ref-arch/matlab-dockerfile.git 22 | cd matlab-dockerfile/alternates/building-on-matlab-docker-image 23 | ``` 24 | 25 | ### Quick Start 26 | Build a container with a name and tag. 27 | ```bash 28 | docker build -t matlab_with_add_ons:R2025a . 29 | ``` 30 | 31 | You can then run the container with the `batch` option. Test the container by running an example MATLAB command, such as `ver`, to display the installed toolboxes. 32 | ```bash 33 | docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab_with_add_ons:R2025a -batch ver 34 | ``` 35 | You can check the installed support packages using the MATLAB command `matlabshared.supportpkg.getInstalled`. 36 | 37 | You can also run the container with the `browser` option to access MATLAB in a browser. 38 | ```bash 39 | docker run --init --rm -it -p 8888:8888 matlab_with_add_ons:R2025a -browser 40 | ``` 41 | For more information, see [Run the Container](#run-the-container). 42 | 43 | ## Customize the Image 44 | ### Customize Products to Install Using MATLAB Package Manager 45 | This Dockerfile installs any specified products 46 | into the MATLAB installation on the MATLAB Docker Hub image. 47 | 48 | To customize the build, either pass a list of products into the `ADDITIONAL_PRODUCTS` 49 | argument when building the Docker image, or edit the default value of that argument in the Dockerfile. 50 | The `ADDITIONAL_PRODUCTS` argument must be a space-separated list surrounded by quotation marks. 51 | By default, `ADDITIONAL_PRODUCTS` includes example products, which you can replace. 52 | For example, to build an image containing MATLAB and the Deep Learning Toolbox™, use this command. 53 | ```bash 54 | docker build --build-arg ADDITIONAL_PRODUCTS="Deep_Learning_Toolbox" -t matlab_with_add_ons:R2025a . 55 | ``` 56 | 57 | For a successful build, include at least one product. 58 | `mpm` automatically installs any toolboxes and support packages 59 | required by the products specified in `ADDITIONAL_PRODUCTS`. 60 | For more information, see [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md). 61 | 62 | You can modify the products argument of `mpm`, but not the destination folder default value, which is 63 | set to match the default value of the MATLAB image on Docker Hub. If you modify the default value for the `--destination` argument, the build might fail. 64 | 65 | ### Docker Build-Time Variables 66 | The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile) supports the Docker build-time variables listed in the table. 67 | 68 | | Argument Name | Default value | Effect | 69 | |---|---|---| 70 | | [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | R2025a | MATLAB release to install, for example, `R2023b`.| 71 | | [ADDITIONAL_PRODUCTS](#customize-products-to-install-using-matlab-package-manager-mpm) | `Symbolic_Math_Toolbox Deep_Learning_Toolbox_Model_for_ResNet-50_Network` | Space-separated list of toolboxes and support packages to install. For more details, see [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md).| 72 | | [LICENSE_SERVER](#build-an-image-with-license-server-information) | *unset* | Port and hostname of a machine that is running a Network License Manager, using the `port@hostname` syntax, for example, `27000@MyServerName`. To use this build argument, the corresponding lines must be uncommented in the Dockerfile. | 73 | 74 | Use these arguments with the `docker build` command to customize the image. 75 | Alternatively, change the default values for these arguments directly in the Dockerfile. 76 | 77 | ### Build an Image for a Different MATLAB Release 78 | 79 | For example, to build an image for MATLAB R2022b, use this command. 80 | ```bash 81 | docker build --build-arg MATLAB_RELEASE=R2022b -t matlab_with_add_ons:R2022b . 82 | ``` 83 | 84 | To build an image for MATLAB R2022b with Deep Learning Toolbox and Parallel Computing Toolbox™, use this command. 85 | ```bash 86 | docker build --build-arg MATLAB_RELEASE=R2022b --build-arg ADDITIONAL_PRODUCTS="Deep_Learning_Toolbox Parallel_Computing_Toolbox" -t matlab_with_add_ons:R2022b . 87 | ``` 88 | For supported releases see [MATLAB Container Image on Docker Hub](https://hub.docker.com/r/mathworks/matlab). 89 | ### Build an Image with License Server Information 90 | If you include the license server information with the `docker build` command, you do not need to pass the information while running the container. 91 | To use this build argument, uncomment the corresponding lines in the Dockerfile. 92 | If the lines are uncommented, `$LICENSE_SERVER` must be a valid license 93 | server or the browser mode will not start successfully. 94 | 95 | Build container with the license server. 96 | ```bash 97 | docker build -t matlab_with_add_ons:R2025a --build-arg LICENSE_SERVER=27000@MyServerName . 98 | ``` 99 | 100 | Run the container, without needing to pass license information. 101 | ```bash 102 | docker run --init matlab_with_add_ons:R2025a -batch ver 103 | ``` 104 | ## Run the Container 105 | The Docker container you build using this Dockerfile inherits run options from its base image. 106 | See the documentation for the base image, [MATLAB Container Image on Docker Hub](https://hub.docker.com/r/mathworks/matlab) (hosted on Docker Hub) for instructions on how to use the base image features. The features include interacting with MATLAB using a web browser, batch mode, or an interactive command prompt, as well as how to provide license information when running the container. 107 | Run the commands provided in the instructions using the name of the Docker image that you build using this Dockerfile. 108 | 109 | ## More MATLAB Docker Resources 110 | For more resources, see [More MATLAB Docker Resources](https://github.com/mathworks-ref-arch/matlab-dockerfile#more-matlab-docker-resources). 111 | 112 | ## Help Make MATLAB Even Better 113 | You 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. 114 | ```Dockerfile 115 | ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=$MW_CONTEXT_TAGS,MATLAB:TOOLBOXES:DOCKERFILE:V1 116 | ``` 117 | 118 | To learn more, see the documentation: [Help Make MATLAB Even Better - Frequently Asked Questions](https://www.mathworks.com/support/faq/user_experience_information_faq.html). 119 | 120 | ## Feedback 121 | We 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). 122 | 123 | ---- 124 | 125 | Copyright 2023-2025 The MathWorks, Inc. 126 | 127 | ---- 128 | -------------------------------------------------------------------------------- /alternates/matlab-container-offline-install/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2024-2025 The MathWorks, Inc. 2 | # This Dockerfile allows you to build a Docker® image with MATLAB® installed using the MATLAB Package 3 | # Manager. Use the optional build arguments to customize the version of MATLAB, list of products to 4 | # install, and the location at which to install MATLAB. 5 | 6 | # Here is an example docker build command with the optional build arguments. 7 | # docker build --build-arg MATLAB_RELEASE=R2025a 8 | # --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox" 9 | # --build-arg MATLAB_INSTALL_LOCATION="/opt/matlab/R2025a" 10 | # -t my_matlab_image_name . 11 | 12 | # To specify which MATLAB release to install in the container, edit the value of the MATLAB_RELEASE argument. 13 | # Use uppercase to specify the release, for example: ARG MATLAB_RELEASE=R2021b 14 | ARG MATLAB_RELEASE=R2025a 15 | 16 | # Specify the list of products to install into MATLAB. 17 | ARG MATLAB_PRODUCT_LIST="MATLAB" 18 | 19 | # Specify the MATLAB Install Location. 20 | ARG MATLAB_INSTALL_LOCATION="/opt/matlab/${MATLAB_RELEASE}" 21 | 22 | # Specify the archive image containing the installation files 23 | ARG ARCHIVE_BASE_IMAGE="mpm-archive:${MATLAB_RELEASE}" 24 | 25 | # Specify license server information using the format: port@hostname 26 | ARG LICENSE_SERVER 27 | 28 | # Specify the archive base image as a stage to allow it to be mounted in a later stage 29 | FROM ${ARCHIVE_BASE_IMAGE} AS archive 30 | 31 | # When you start the build stage, this Dockerfile by default uses the Ubuntu-based matlab-deps image. 32 | # To check the available matlab-deps images, see: https://hub.docker.com/r/mathworks/matlab-deps 33 | FROM mathworks/matlab-deps:${MATLAB_RELEASE} 34 | 35 | # Declare build arguments to use at the current build stage. 36 | ARG MATLAB_PRODUCT_LIST 37 | ARG MATLAB_INSTALL_LOCATION 38 | ARG LICENSE_SERVER 39 | 40 | # Add "matlab" user and grant sudo permission. 41 | RUN adduser --shell /bin/bash --disabled-password --gecos "" matlab \ 42 | && echo "matlab ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/matlab \ 43 | && chmod 0440 /etc/sudoers.d/matlab 44 | 45 | # Set user and work directory. 46 | USER matlab 47 | WORKDIR /home/matlab 48 | 49 | # Run mpm to install MATLAB in the target location and delete the mpm installation afterwards. 50 | # If mpm fails to install successfully, then print the logfile in the terminal, otherwise clean up. 51 | # Pass in $HOME variable to install support packages into the user's HOME folder. 52 | RUN --mount=type=bind,from=archive,source=/,target=/mpm-download/ \ 53 | sudo HOME=${HOME} /mpm-download/mpm/glnxa64/mpm install \ 54 | --source=/mpm-download/archives \ 55 | --destination=${MATLAB_INSTALL_LOCATION} \ 56 | ${MATLAB_PRODUCT_LIST} \ 57 | || (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \ 58 | && sudo rm -rf /tmp/mathworks_root.log \ 59 | && sudo ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab 60 | 61 | 62 | # Note: Uncomment one of the following two ways to configure the license server. 63 | 64 | # Option 1. Specify the host and port of the machine that serves the network licenses 65 | # if you want to store the license information in an environment variable. This 66 | # is the preferred option. You can either use a build variable, like this: 67 | # --build-arg LICENSE_SERVER=27000@MyServerName or you can specify the license server 68 | # directly using: ENV MLM_LICENSE_FILE=27000@flexlm-server-name 69 | ENV MLM_LICENSE_FILE=$LICENSE_SERVER 70 | 71 | # Option 2. Alternatively, you can put a license file into the container. 72 | # Enter the details of the license server in this file and uncomment the following line. 73 | # COPY network.lic ${MATLAB_INSTALL_LOCATION}/licenses/ 74 | 75 | # The following environment variables allow MathWorks to understand how this MathWorks 76 | # product is being used. This information helps us make MATLAB even better. 77 | # Your content, and information about the content within your files, is not shared with MathWorks. 78 | # To opt out of this service, delete the environment variables defined in the following line. 79 | # See the Help Make MATLAB Even Better section in the accompanying README to learn more: 80 | # https://github.com/mathworks-ref-arch/matlab-dockerfile/alternates/matlab-container-offline-install#help-make-matlab-even-better 81 | ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=$MW_CONTEXT_TAGS,MATLAB:FROM_SOURCE:DOCKERFILE:V1 82 | 83 | ENTRYPOINT ["matlab"] 84 | CMD [""] -------------------------------------------------------------------------------- /alternates/matlab-container-offline-install/README.md: -------------------------------------------------------------------------------- 1 | # Install MATLAB and Add-Ons in Containers in an Offline Environment 2 | 3 | The Dockerfiles in this subfolder show you how to build and customize a Docker® container for MATLAB® and its toolboxes, using the [MATLAB Package Manager (*mpm*)](../../MPM.md) in an offline environment where *mpm* is not able to download the toolbox installation files. Use this solution only if you need to install MATLAB, toolboxes, and support packages in an air-gapped environment. Otherwise, use the [`Dockerfile`](../../Dockerfile) in the top-level repository. 4 | 5 | The solution uses two Docker images. The first image (archive image) contains the installation files that are required by *mpm* to install from source. The second image (product image) uses the archive image to get the installation files for MATLAB, toolboxes and support packages that you want to install. 6 | 7 | ### Requirements 8 | * [A Running Network License Manager for MATLAB](https://www.mathworks.com/help/install/administer-network-licenses.html) 9 | * For more information, see [Use the Network License Manager](../../README.md#use-the-network-license-manager) 10 | * Docker >= 20.10 11 | 12 | ## Build Instructions 13 | 14 | ### Get the Dockerfiles 15 | 16 | Access the Dockerfiles either by directly downloading this repository from GitHub®, or by cloning this repository and then navigating to the appropriate subfolder. You must have a working internet connection to perform this action. 17 | 18 | ```bash 19 | git clone https://github.com/mathworks-ref-arch/matlab-dockerfile.git 20 | cd matlab-dockerfile/alternates/matlab-container-offline-install 21 | ``` 22 | ### Build the Archive Docker Image 23 | > :warning: Note: You must run this step in an online environment. 24 | 25 | You can then store the generated Docker build and copy it to the offline or air-gapped environment for the next step. 26 | 27 | Build the archive image with a name and tag. 28 | ```bash 29 | docker build -t mpm-archive:R2025a -f archive.Dockerfile . 30 | ``` 31 | 32 | By default, the [archive.Dockerfile](archive.Dockerfile) downloads the latest available MATLAB release without any additional toolboxes or products. 33 | 34 | To customize the build of the archive image, refer to [Customize the Archive Docker Image](#customize-the-archive-docker-image). 35 | 36 | ### Build the Product Docker Image 37 | To run this step in an offline or air-gapped environment, you need: 38 | * The [mathworks/matlab-deps](https://hub.docker.com/r/mathworks/matlab-deps) image in your local Docker registry. 39 | * The mpm-archive image in your local Docker registry. 40 | * A Docker environment with [BuildKit enabled](https://docs.docker.com/build/buildkit/#getting-started). 41 | 42 | Build a container with a name and tag. 43 | ```bash 44 | DOCKER_BUILDKIT=1 docker build -t matlab-from-source:R2025a . 45 | ``` 46 | 47 | To customize the build of the product image, refer to [Customize the Product Docker Image](#customize-the-product-docker-image). 48 | 49 | ## Customization Instructions 50 | Follow these instructions if you want to customize the build of the archive and product Docker images. 51 | 52 | ### Customize the Archive Docker Image 53 | The [archive.Dockerfile](archive.Dockerfile) supports the following Docker build-time variables: 54 | 55 | | Argument Name | Default value | Effect | 56 | |---|---|---| 57 | | [MATLAB_RELEASE](#build-an-archive-image-for-a-different-release-of-matlab) | R2025a | The MATLAB release to install, for example, `R2023b`. | 58 | | [MATLAB_PRODUCT_LIST](#build-an-archive-image-with-a-specific-set-of-products) | MATLAB | Products to install as a space-separated list. For more information, see [MPM.md](../../MPM.md). For example: `MATLAB Simulink Deep_Learning_Toolbox Fixed-Point_Designer` | 59 | 60 | Use these arguments with the `docker build` command to customize your image. 61 | Alternatively, you can change the default values for these arguments directly in the [archive.Dockerfile](archive.Dockerfile). 62 | 63 | #### Build an Archive Image for a Different Release of MATLAB 64 | 65 | For example, to build an archive image for MATLAB R2023b installation files, use the following command. 66 | ```bash 67 | docker build --build-arg MATLAB_RELEASE=R2023b -t mpm-archive:R2023b -f archive.Dockerfile . 68 | ``` 69 | 70 | #### Build an Archive Image with a specific set of products 71 | 72 | For example, to build an image with MATLAB and the Statistics and Machine Learning Toolbox™ installation files, use this command. 73 | ```bash 74 | docker build --build-arg MATLAB_PRODUCT_LIST="MATLAB Statistics_and_Machine_Learning_Toolbox" -t mpm-archive:R2025a -f archive.Dockerfile . 75 | ``` 76 | 77 | ### Customize the Product Docker Image 78 | The [Dockerfile](Dockerfile) supports the following Docker build-time variables: 79 | 80 | | Argument Name | Default value | Effect | 81 | |---|---|---| 82 | | [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | R2025a | The MATLAB release you want to install, in lower-case. For example: `R2022a`. :warning: This release must match the `MATLAB_RELEASE` you use to build the archive image. | 83 | | [MATLAB_PRODUCT_LIST](#build-an-image-with-a-specific-set-of-products) | MATLAB | Products to install as a space-separated list. For more information, see [MPM.md](../../MPM.md). For example: `MATLAB Simulink Deep_Learning_Toolbox Fixed-Point_Designer`. The list of products to install must be a subset of the installation files available in the archive image. | 84 | | [MATLAB_INSTALL_LOCATION](#build-an-image-with-matlab-installed-to-a-specific-location) | /opt/matlab/R2025a | The path to install MATLAB. | 85 | | [ARCHIVE_BASE_IMAGE](#build-an-image-from-a-different-archive) | mpm-archive:R2025a | The name of the Docker® image containing the product installation files. | 86 | | [LICENSE_SERVER](#build-an-image-configured-to-use-a-license-server) | *unset* | The port and hostname of the machine that is running the Network License Manager, using the `port@hostname` syntax. For example: `27000@MyServerName` | 87 | 88 | Use these arguments with the `docker build` command to customize your image. 89 | Alternatively, you can change the default values for these arguments directly in the [Dockerfile](Dockerfile). 90 | 91 | 92 | ### Build an Image for a Different Release of MATLAB 93 | 94 | For example, to build an image for MATLAB R2023b, use the following command. 95 | ```bash 96 | docker build --build-arg MATLAB_RELEASE=R2023b --build-arg ARCHIVE_BASE_IMAGE=mpm-archive:R2023b -t matlab-from-source:R2023b . 97 | ``` 98 | Ensure that the release of the archive base image you set in `ARCHIVE_BASE_IMAGE` matches the one in `MATLAB_RELEASE`. 99 | 100 | ### Build an Image with a Specific Set of Products 101 | 102 | For example, to build an image with MATLAB and the Statistics and Machine Learning Toolbox, use this command. 103 | ```bash 104 | docker build --build-arg MATLAB_PRODUCT_LIST="MATLAB Statistics_and_Machine_Learning_Toolbox" -t matlab-stats-from-source:R2025a . 105 | ``` 106 | 107 | ### Build an Image with MATLAB Installed to a Specific Location 108 | 109 | For example, to build an image with MATLAB installed at `/opt/matlab`, use this command. 110 | ```bash 111 | docker build --build-arg MATLAB_INSTALL_LOCATION="/opt/matlab" -t matlab-from-source:R2025a . 112 | ``` 113 | 114 | ### Build an Image from a Different Archive 115 | 116 | For example, to build an image using a different archive image, use the following command. 117 | ```bash 118 | docker build --build-arg ARCHIVE_BASE_IMAGE=my-archive -t matlab-from-source:R2025a . 119 | ``` 120 | 121 | #### Build an Image Configured to Use a License Server 122 | 123 | Including the license server information with the `docker build` command means you do not have to pass it when running the container. 124 | ```bash 125 | # Build container with the License Server. 126 | docker build --build-arg LICENSE_SERVER=27000@MyServerName -t matlab-from-source:R2025a . 127 | 128 | # Run the container, without needing to pass license information. 129 | docker run --init --rm matlab-from-source:R2025a -batch ver 130 | ``` 131 | 132 | For more information, see [Use the Network License Manager](../../README.md#use-the-network-license-manager). 133 | 134 | ## More MATLAB Docker Resources 135 | For more MATLAB Docker resources, see [More MATLAB Docker Resources](../../README.md#more-matlab-docker-resources). 136 | 137 | ## Help Make MATLAB Even Better 138 | You 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 the following line in the Dockerfile: 139 | ```Dockerfile 140 | ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=MATLAB:FROM_SOURCE:DOCKERFILE:V1 141 | ``` 142 | 143 | To learn more, see the documentation: [Help Make MATLAB Even Better - Frequently Asked Questions](https://www.mathworks.com/support/faq/user_experience_information_faq.html). 144 | 145 | ## Feedback 146 | We 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). 147 | 148 | --- 149 | Copyright 2024-2025 The MathWorks, Inc. 150 | -------------------------------------------------------------------------------- /alternates/matlab-container-offline-install/archive.Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2024-2025 The MathWorks, Inc. 2 | 3 | # Here is an example docker build command with the optional build arguments. 4 | # docker build --build-arg MATLAB_RELEASE=R2025a 5 | # --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox" 6 | # -f archive.Dockerfile 7 | # -t mpm-archive . 8 | 9 | # To specify which MATLAB release to install in the container, edit the value of the MATLAB_RELEASE argument. 10 | # Use uppercase to specify the release, for example: ARG MATLAB_RELEASE=R2021b 11 | ARG MATLAB_RELEASE=R2025a 12 | 13 | # Specify the list of products to install into MATLAB. 14 | ARG MATLAB_PRODUCT_LIST="MATLAB" 15 | 16 | # The staging location used to store the downloaded mpm archives 17 | ARG MPM_DOWNLOAD_DESTINATION="/usr/local/src" 18 | 19 | # Download MPM and installation files in a mathworks/matlab-deps Docker image 20 | # This guarantees that all dependencies are already installed 21 | FROM mathworks/matlab-deps:${MATLAB_RELEASE} AS download 22 | 23 | # Declare build arguments to use at the current build stage. 24 | ARG MATLAB_RELEASE 25 | ARG MATLAB_PRODUCT_LIST 26 | ARG MPM_DOWNLOAD_DESTINATION 27 | 28 | # Install mpm dependencies. 29 | RUN export DEBIAN_FRONTEND=noninteractive \ 30 | && apt-get update \ 31 | && apt-get install --no-install-recommends --yes \ 32 | wget \ 33 | ca-certificates \ 34 | && apt-get clean \ 35 | && apt-get autoremove \ 36 | && rm -rf /var/lib/apt/lists/* 37 | 38 | # Run mpm to install MATLAB in the target location. 39 | # If mpm fails to install successfully, then print the logfile in the terminal, otherwise clean up. 40 | RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \ 41 | && chmod +x mpm \ 42 | && ./mpm download \ 43 | --release=${MATLAB_RELEASE} \ 44 | --destination=${MPM_DOWNLOAD_DESTINATION} \ 45 | --products ${MATLAB_PRODUCT_LIST} \ 46 | && chmod +x ${MPM_DOWNLOAD_DESTINATION}/mpm/glnxa64/mpm \ 47 | || (echo "MPM Download Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) 48 | 49 | # Move MPM and the installation files to a scratch image 50 | FROM scratch 51 | 52 | # Declare build arguments to use at the current build stage. 53 | ARG MPM_DOWNLOAD_DESTINATION 54 | 55 | COPY --from=download ${MPM_DOWNLOAD_DESTINATION} / 56 | -------------------------------------------------------------------------------- /alternates/matlab-installer/.gitignore: -------------------------------------------------------------------------------- 1 | matlab-install 2 | !tests/mocks/matlab-install 3 | matlab_installer_input.txt 4 | !tests/mocks/matlab_installer_input.txt 5 | 6 | -------------------------------------------------------------------------------- /alternates/matlab-installer/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2025 The MathWorks, Inc. 2 | 3 | # To specify which MATLAB release you wish to install in the container, edit the value of the MATLAB_RELEASE argument. 4 | # Use lower case to specify the release. 5 | ARG MATLAB_RELEASE=r2025a 6 | 7 | FROM ubuntu as versioner 8 | 9 | ARG MATLAB_RELEASE 10 | 11 | COPY matlab-install/VersionInfo.xml /VersionInfo.xml 12 | 13 | RUN RELEASE=`sed -ne "s/.*\(.*\)<\/release>.*/\L\1/p" /VersionInfo.xml` \ 14 | && if [ "$MATLAB_RELEASE" != "$RELEASE" ]; then echo "Provided release (${MATLAB_RELEASE}) does not match release found in VersionInfo.xml ($RELEASE)"; exit 1; fi 15 | 16 | # When you start the build stage, this Dockerfile uses the mathworks/matlab-deps image related to the chosen release. 17 | # This base image contains the required dependencies of the chosen MATLAB release. 18 | # To check the available mathworks/matlab-deps images, see: https://hub.docker.com/r/mathworks/matlab. 19 | FROM mathworks/matlab-deps:${MATLAB_RELEASE} as base 20 | 21 | # Switch to root's home directory to avoid polluting the / directory. 22 | WORKDIR /root 23 | 24 | # Install MATLAB in a multi-build style. 25 | FROM base as middle-stage 26 | 27 | ###### 28 | # Create a self-contained MATLAB installer using these instructions: 29 | # 30 | # https://www.mathworks.com/help/install/ug/download-only.html 31 | # 32 | # You must be an administrator on your license to complete this workflow. 33 | # You can run the installer on any platform to create a self-contained MATLAB installer. 34 | # When creating the installer, on the "Folder and Platform Selection" screen, select "Linux (64-bit)". 35 | # 36 | # Put the installer in a directory called matlab-install. 37 | # Move that matlab-install folder to be in the same folder as this Dockerfile. 38 | ###### 39 | 40 | # Add the extracted MATLAB installer to the image 41 | COPY matlab-install /matlab-install/ 42 | 43 | # Copy the file matlab-install/installer_input.txt into the same folder as the 44 | # Dockerfile and edit this file to specify the products that you want to install. 45 | # Note that you must change the following set of parameters in the file: 46 | # fileInstallationKey 47 | # agreeToLicense=yes 48 | # Uncomment products you want to install 49 | COPY matlab_installer_input.txt /matlab_installer_input.txt 50 | 51 | # For installs prior to R2020a, uncomment one of the following 2 ways of adding the license file. 52 | # If you use a release of MATLAB after, and including, R2020a both methods can be commented out. 53 | # If this is done, either mount a license file or specify a license server at runtime. 54 | # You must also comment out the commands directly after the install relating to the license file. 55 | 56 | # The first way to add a license file is to use the LICENSE_SERVER argument to automatically 57 | # generate a valid network.lic file. 58 | # Print this file out to verify that it has been generated successfully. 59 | ARG LICENSE_SERVER 60 | RUN SERVER=$(echo ${LICENSE_SERVER} | sed 's/.*@//') \ 61 | && PORT=$(echo ${LICENSE_SERVER} | sed 's/@.*//') \ 62 | && printf "SERVER ${SERVER} ${PORT}\nUSE_SERVER\n" > /tmp/network.lic \ 63 | && cat /tmp/network.lic 64 | 65 | # Alternatively you can supply a network license file directly into the container. 66 | # Fill this file with the details of the license server you want to use and uncomment the following line. 67 | # COPY network.lic /tmp/network.lic 68 | 69 | # The following commands are used to set installation information specific to the installation of MATLAB 70 | # within the docker image. 71 | # This replaces the command line flags as not all versions support them. 72 | RUN sed -i 's/# destinationFolder=$/destinationFolder=\/usr\/local\/MATLAB/' /matlab_installer_input.txt \ 73 | && sed -i 's/# licensePath=$/licensePath=\/tmp\/network.lic/' /matlab_installer_input.txt \ 74 | && sed -i 's/# outputFile=$/outputFile=\/tmp\/install.log/' /matlab_installer_input.txt 75 | 76 | # Now install MATLAB 77 | RUN cd /matlab-install \ 78 | && chmod +x ./install \ 79 | && ./install \ 80 | -mode silent \ 81 | -inputFile /matlab_installer_input.txt \ 82 | && if ! [ -f /usr/local/MATLAB/bin/matlab ]; then \ 83 | cat /tmp/install.log \ 84 | && echo "Installation failed and MATLAB was not installed. See the build log above for more information"; \ 85 | exit 1; fi 86 | 87 | # If you did not specify a license server at build, comment these lines. 88 | RUN mkdir -p /usr/local/MATLAB/licenses \ 89 | && cp /tmp/network.lic /usr/local/MATLAB/licenses/ 90 | 91 | # Build final container image. 92 | FROM base 93 | 94 | COPY --from=middle-stage /usr/local/MATLAB /usr/local/MATLAB 95 | 96 | # Soft link MATLAB into /usr/local/bin. 97 | RUN ln -s /usr/local/MATLAB/bin/matlab /usr/local/bin/matlab 98 | 99 | # Add a user other than root to run MATLAB. 100 | RUN useradd -ms /bin/bash matlab 101 | 102 | # Add give that user sudo privileges. 103 | RUN echo "matlab ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/matlab \ 104 | && chmod 0440 /etc/sudoers.d/matlab 105 | 106 | # Finally clean up after apt-get. 107 | RUN apt-get clean \ 108 | && apt-get -y autoremove \ 109 | && rm -rf /var/lib/apt/lists/* 110 | 111 | # The following environment variables allow MathWorks to understand how this MathWorks 112 | # product (MATLAB Dockerfile) is being used. This information helps us make MATLAB even better. 113 | # Your content, and information about the content within your files, is not shared with MathWorks. 114 | # To opt out of this service, delete the environment variables defined in the following line. 115 | # See the Help Make MATLAB Even Better section in the accompanying README to learn more: 116 | # https://github.com/mathworks-ref-arch/matlab-dockerfile#help-make-matlab-even-better 117 | ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=MATLAB:MATLAB_INSTALLER:DOCKERFILE:V1 118 | 119 | # Set user and work directory. 120 | USER matlab 121 | WORKDIR /home/matlab 122 | ENTRYPOINT ["matlab"] 123 | CMD [""] 124 | -------------------------------------------------------------------------------- /alternates/matlab-installer/README.md: -------------------------------------------------------------------------------- 1 | # Create MATLAB Container Image Using MATLAB Installer 2 | 3 | This repository demonstrates how to create a Docker® container image for MATLAB® from local files using the MATLAB installer on a Linux® Operating System. To create a container image for other operating systems, use the appropriate commands. This method provided here uses the MATLAB installer rather than [MATLAB Package Manager (`mpm`)](../../MPM.md). The MATLAB installer is the default graphical installer for MATLAB. 4 | 5 | The Dockerfile in this subfolder shows you how to use the MATLAB installer with the `-mode silent` flag to install MATLAB without a graphical user interface. Use this Dockerfile if either of these conditions apply. 6 | - You need toolboxes that `mpm` cannot install. 7 | - You prefer using the MATLAB installer workflow, for example, if you have already set it up in your CI/CD pipeline. 8 | 9 | If not, use the [simpler workflow](../../README.md) to build a container image using `mpm`. 10 | 11 | Use the container image as a scalable and reproducible method to deploy MATLAB in a variety of situations, including clouds and clusters. 12 | 13 | ## Requirements 14 | * Docker 15 | * Git™ 16 | 17 | ## Step 1. Clone This Repository 18 | 1. Clone this repository using this command. 19 | ```bash 20 | git clone https://github.com/mathworks-ref-arch/matlab-dockerfile.git 21 | ``` 22 | 2. Inside the cloned repository, navigate to the `alternates/matlab-installer` folder. 23 | 3. Create a subfolder named `matlab-install`. 24 | 25 | ## Step 2. Choose MATLAB Installation Method 26 | To install MATLAB into the container image, choose a MATLAB installation method. You can either use MATLAB installation files or a MATLAB ISO image. 27 | 28 | ### MATLAB Installation Files 29 | To obtain the installation files, you must be an administrator for the license linked with your MathWorks® account. 30 | 1. From the [MathWorks Downloads](https://www.mathworks.com/downloads/) page, select the desired version of MATLAB. 31 | 1. Download the Installer for Linux. 32 | 1. Follow the steps at [Download Products Without Installation](https://www.mathworks.com/help/install/ug/download-without-installing.html). 33 | 1. Specify the location of the `matlab-install` subfolder of the cloned repository as the path to the download folder. 34 | 1. Select the installation files for the Linux (64-bit) version of MATLAB. 35 | 1. Select the products you want to install in the container image. 36 | 1. Confirm your selections and complete the download. 37 | 1. **(For MATLAB releases after R2020a)** The installation files are extracted automatically into a subfolder with a date stamp. Move these files up a level using this command from the `matlab-installer` folder. 38 | ```bash 39 | mv ./matlab-install/