You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-53
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,8 @@
1
-
# Create a MATLAB Container Image
1
+
# Create MATLAB Container Image
2
2
3
-
This repository shows you how to build and customize a Docker® container for MATLAB® and its toolboxes, using the [MATLAB Package Manager (*mpm*)](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md).
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
4
5
-
You can use this container image as a scalable and reproducible method to deploy and test your MATLAB code.
6
-
7
-
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 this Dockerfile from [here](https://github.com/mathworks-ref-arch/matlab-dockerfile/pkgs/container/matlab-dockerfile%2Fmatlab).
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).
8
6
9
7
For alternative resources, see the [**alternates folder**](alternates) that contains the following Dockerfiles:
10
8
@@ -16,77 +14,76 @@ For alternative resources, see the [**alternates folder**](alternates) that cont
16
14
For more Docker related resources, see [More MATLAB Docker Resources](#more-matlab-docker-resources).
17
15
18
16
### Requirements
19
-
*[A Running Network License Manager for MATLAB](https://www.mathworks.com/help/install/administer-network-licenses.html)
20
-
* For more information, see [Using the Network License Manager](#use-the-network-license-manager)
21
-
* Docker
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.
22
19
23
20
## Build Instructions
24
21
25
22
### Get Sources
26
23
27
-
Access this Dockerfile either by directly downloading this repository from GitHub®,
24
+
Access the Dockerfile either by directly downloading this repository from GitHub®,
Build container with a name and tag of your choice.
38
35
```bash
39
36
docker build -t matlab:R2024b .
40
37
```
41
38
42
-
Run the container. Test the container by running an example MATLAB command such as ver.
39
+
Run the container. Test the container by running an example MATLAB command, such as `ver`.
43
40
```bash
44
41
docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2024b -batch ver
45
42
```
46
43
The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile) defaults to building a container for MATLAB R2024b.
47
44
48
-
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 section on [Running the Container](#run-the-container).
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.
49
46
50
47
> **Note**
51
48
>
52
-
> Using the `--init` flag in the `docker run` command ensures that the container stops gracefully when a `docker stop` or `docker kill` command is issued.
53
-
> For more information, see the following links:
54
-
> *[Docker run reference page](https://docs.docker.com/reference/cli/docker/container/run/#init).
55
-
> *[Blog post on the usage of init](https://www.baeldung.com/ops/docker-init-parameter).
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)
56
53
57
54
58
55
## Customize the Image
59
56
60
-
By default, the [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile) installs MATLAB for the latest available MATLAB release without any additional toolboxes or products in the `/opt/matlab/${MATLAB_RELEASE}` folder.
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.
61
58
62
59
Use the options below to customize your build.
63
60
64
-
### Customize MATLAB Release, MATLAB Product List, MATLAB Install Location and License Server
65
-
The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile) supports the following Docker build-time variables:
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:
66
63
67
64
| Argument Name | Default value | Description |
68
65
|---|---|---|
69
-
|[MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab)| R2024b |The MATLAB release to install, for example, `R2023b`.|
70
-
|[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](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md). For example: `MATLAB Simulink Deep_Learning_Toolbox Fixed-Point_Designer`|
71
-
|[MATLAB_INSTALL_LOCATION](#build-an-image-with-matlab-installed-to-a-specific-location)| /opt/matlab/R2024b |The path to install MATLAB. |
72
-
|[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`|
66
+
|[MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab)| R2024b | 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/R2024b |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`|
73
70
74
71
Use these arguments with the the `docker build` command to customize your image.
75
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).
76
73
77
-
#### Build an Image for a Different Release of MATLAB
74
+
#### Build an Image for a Different MATLAB Release
78
75
For example, to build an image for MATLAB R2019b, use this command.
# Run the container, without needing to pass license information.
99
+
# Run the container without needing to pass license information.
103
100
docker run --init --rm matlab:R2024b -batch ver
104
101
```
105
102
106
103
## Use the Network License Manager
107
-
This container requires a Network License Manager to license and run MATLAB. You will need either the port and hostname of the Network License Manager, or a `network.lic` file.
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.
108
105
109
106
**Step 1**: Contact your system administrator, who can provide one of the following:
110
107
111
-
1. The address to your server, and the port it is running on.
* The address to your server, and the port it is running on, for example, `[email protected]`
113
109
114
-
2. A `network.lic` file which contains the following lines:
110
+
* A `network.lic` file containing these lines.
115
111
```bash
116
112
# Sample network.lic
117
113
SERVER MyServerName.example.com <optional-mac-address> 27000
118
114
USE_SERVER
119
115
```
120
116
121
-
3. 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.
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.
122
118
123
119
```bash
124
-
#snippet from sample license.dat
120
+
#Snippet from sample license.dat
125
121
SERVER MyServerName.example.com <mac-address> 27000
126
122
```
127
123
---
@@ -135,17 +131,17 @@ With the `docker build` command, either:
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`.
156
152
157
153
```bash
158
-
# Start MATLAB, print version information, and exit:
154
+
# Start MATLAB, print version information, and exit.
159
155
docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2024b -batch ver
160
156
```
161
157
162
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.
163
159
164
160
### Run MATLAB in an Interactive Command Prompt
165
-
To start the container and run MATLAB in an interactive command prompt, execute:
161
+
To start the container and run MATLAB in an interactive command prompt, use this command.
166
162
```bash
167
163
docker run --init -it --rm matlab:R2024b
168
164
```
169
165
### Run MATLAB in Batch Mode
170
-
To start the container, run a MATLAB command, and then exit, execute:
166
+
To start the container, run a MATLAB command, and then exit, use this command.
171
167
```bash
172
168
# Container runs the command RAND in MATLAB and exits.
173
169
docker run --init --rm matlab:R2024b -batch rand
174
170
```
175
171
176
172
### Run MATLAB with Startup Options
177
-
To override the default behavior of the container and run MATLAB with any set of arguments, such as `-logfile`, execute:
173
+
To override the default behavior of the container and run MATLAB with any set of arguments, such as `-logfile`, use this command.
178
174
```bash
179
175
docker run --init -it --rm matlab:R2024b -logfile "logfilename.log"
180
176
```
181
177
To learn more, see the documentation: [Commonly Used Startup Options](https://www.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html).
182
178
183
179
184
180
## More MATLAB Docker Resources
185
-
* Explore prebuilt MATLAB Docker Containers on Docker Hub: https://hub.docker.com/r/mathworks
181
+
* Explore prebuilt MATLAB Docker Containers on Docker Hub: https://hub.docker.com/r/mathworks.
186
182
* [MATLAB Containers on Docker Hub](https://hub.docker.com/r/mathworks/matlab) hosts container images for multiple releases of MATLAB.
187
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.
188
-
* Enable additional capabilities using the [MATLAB Dependencies repository](https://github.com/mathworks-ref-arch/container-images/tree/master/matlab-deps).
189
-
For some workflows and toolboxes, you must specify dependencies. You must do this if you want to do any of the following tasks:
190
-
* Install extended localization support for MATLAB.
191
-
* Play media files from MATLAB.
192
-
* Generate code from Simulink.
193
-
* Use mex functions with gcc, g++, or gfortran.
194
-
* Use the MATLAB Engine API for C and Fortran®.
195
-
* Use the Polyspace® 32-bit tcc compiler.
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
196
192
197
-
The [matlab-deps repository](https://github.com/mathworks-ref-arch/container-images/tree/main/matlab-deps) repository lists Dockerfiles for various releases and platforms. To view the Dockerfile for R2024b, click [here](https://github.com/mathworks-ref-arch/container-images/blob/main/matlab-deps/r2024b/ubuntu22.04/Dockerfile).
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 R2024b, click [here](https://github.com/mathworks-ref-arch/container-images/blob/main/matlab-deps/r2024b/ubuntu22.04/Dockerfile).
198
194
199
-
These Dockerfiles contain commented lines with the libraries that support these additional capabilities. Copy and uncomment these lines into your Dockerfile.
195
+
These Dockerfiles contain commented lines with the libraries that support additional capabilities. Copy and uncomment these lines into your Dockerfile.
200
196
201
197
## Help Make MATLAB Even Better
202
-
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:
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.
0 commit comments