This repository shows you how to build and customize a Windows® Docker® container for MATLAB® and its toolboxes, using the MATLAB Package Manager (mpm) and MATLAB Batch Licensing (matlab-batch). You can use this container image as a scalable and reproducible method to deploy and test your MATLAB code on a Windows platform.
Use this Dockerfile if you have a MATLAB batch licensing token to license MATLAB in your container. The MATLAB batch licensing project is still in the pilot phase. To inquire about eligibility requirements, fill out this form on the MathWorks® website: Batch Licensing Pilot Eligibility.
- MATLAB Batch Licensing Token. For more information, see Use MATLAB Batch Licensing.
- Docker Desktop for Windows® (Windows 10 or later) or a Windows Server® build host (Windows Server 2016 or later).
Access this Dockerfile either by directly downloading this repository from GitHub®, or by cloning this repository and then navigating to the appropriate subfolder.
git clone https://github.com/mathworks-ref-arch/matlab-dockerfile.git
cd matlab-dockerfile/windows/Build container with a name and tag of your choice.
docker build -t matlab-on-windows:R2026a .This Dockerfile defaults to building a Windows container for MATLAB R2026a. The Dockerfile is based on the Windows base image which contains the full Windows API set. For details, see the documentation on DockerHub for Windows base image.
Test the container by running an example MATLAB command, such as ver. The entry point of the container is PowerShell.
docker run --rm matlab-on-windows:R2026a matlab-batch "-licenseToken" "user@email.com::encodedToken" "ver"For more information on running the container, see Run the Container.
By default, the Dockerfile installs the latest available MATLAB release without any additional toolboxes or products, as well as the latest version of matlab-batch.
Use the options below to customize your build.
The Dockerfile supports these Docker build-time variables:
| Argument Name | Default Value | Description |
|---|---|---|
| MATLAB_RELEASE | R2026a | MATLAB release to install, for example, R2023b. |
| MATLAB_PRODUCT_LIST | MATLAB | Space-separated list of products to install. For help specifying the products to install, see the "products" input argument on the documentation page for the mpm install function. For example: MATLAB Simulink Deep_Learning_Toolbox Fixed-Point_Designer |
Use these arguments with the docker build command to customize your image.
Alternatively, the default values for these arguments can be changed directly in the Dockerfile.
Note: MATLAB is installed to
C:\MATLABin the Windows container because the defaultmatlabrootlocation can cause issues with compiler products. For details about the issues, see Build Process Support for File and Folder Names and this MATLAB Answer. Additionally, you cannot use the suggested 8.3 short file names as a workaround because it is not supported in Windows containers. For details, see this GitHub issue.
For example, to build an image for MATLAB R2021b, use this command.
docker build --build-arg MATLAB_RELEASE=R2021b -t matlab-windows:R2021b .For supported releases, see MATLAB Batch Licensing support.
For example, to build an image with MATLAB and the Statistics and Machine Learning Toolbox™, use this command.
docker build --build-arg MATLAB_PRODUCT_LIST="MATLAB Statistics_and_Machine_Learning_Toolbox" -t matlab-stats-windows:R2026a .To start a container and run MATLAB with a MATLAB batch licensing token, open a Windows PowerShell and enter this command:
# Start MATLAB, display 'hello world', and exit.
docker run --rm matlab-on-windows:R2026a matlab-batch -licenseToken 'user@email.com::encodedToken' '\"disp(''hello world'')\"'Note that you must use the rules for using single and double quotation marks in PowerShell. For details, see about quoting rules.
Alternatively, you can run a script myscript.m containing MATLAB code:
# Launch MATLAB, run `myscript.m` and exit:
docker run --mount "type=bind,src=C:\scripts,target=C:\pwd" --workdir "C:\pwd" --rm matlab-on-windows:R2026a matlab-batch -licenseToken 'user@email.com::encodedToken' 'myscript'You can also set your MATLAB batch licensing token at the container level by setting the MLM_LICENSE_TOKEN environment variable. For example:
# Start MATLAB, display 'hello world', and exit.
docker run -e MLM_LICENSE_TOKEN='user@email.com::encodedToken' --rm matlab-on-windows:R2026a matlab-batch '\"disp(''hello world'')\"'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.
Copyright 2025-2026 The MathWorks, Inc.