Skip to content

Commit b769883

Browse files
epaganonprabhakk-mw
authored andcommitted
Introduces environment variables to add font and apt packages.
1 parent 876484e commit b769883

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

alternates/building-on-matlab-docker-image/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@ ARG MATLAB_RELEASE=R2025b
77
# Specify the extra products to install into the image. These products can either be toolboxes or support packages.
88
ARG ADDITIONAL_PRODUCTS="Symbolic_Math_Toolbox Deep_Learning_Toolbox_Model_for_ResNet-50_Network"
99

10+
# Specify the fonts packages to install into the image. The default value below installs fonts for ja_JP-UTF-8 locales support.
11+
ARG FONTS_PACKAGES="fonts-vlgothic ibus-mozc"
12+
13+
# Specify the extra Ubuntu APT packages to install into the image.
14+
ARG ADDITIONAL_APT_PACKAGES=""
15+
1016
# This Dockerfile builds on the Ubuntu-based mathworks/matlab image.
1117
# To check the available matlab images, see: https://hub.docker.com/r/mathworks/matlab
1218
FROM mathworks/matlab:$MATLAB_RELEASE
1319

1420
# Declare the global argument to use at the current build stage
1521
ARG MATLAB_RELEASE
1622
ARG ADDITIONAL_PRODUCTS
23+
ARG FONTS_PACKAGES
24+
ARG ADDITIONAL_APT_PACKAGES
1725

1826
# By default, the MATLAB container runs as user "matlab". To install mpm dependencies, switch to root.
1927
USER root
@@ -24,6 +32,8 @@ RUN export DEBIAN_FRONTEND=noninteractive \
2432
&& apt-get install --no-install-recommends --yes \
2533
wget \
2634
ca-certificates \
35+
${FONTS_PACKAGES} \
36+
${ADDITIONAL_APT_PACKAGES} \
2737
&& apt-get clean \
2838
&& apt-get autoremove \
2939
&& rm -rf /var/lib/apt/lists/*

alternates/building-on-matlab-docker-image/README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/ma
6969
|---|---|---|
7070
| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | R2025b | MATLAB release to install, for example, `R2023b`.|
7171
| [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+
| [FONTS_PACKAGES](#build-an-image-with-modified-fonts-packages) | `fonts-vlgothic ibus-mozc` | Space-separated list of fonts packages to install. |
73+
| [ADDITIONAL_APT_PACKAGES](#build-an-image-with-additional-ubuntu-apt-packages) | *unset* | Space-separated list of APT packages to install. |
7274
| [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. |
7375

7476
Use these arguments with the `docker build` command to customize the image.
@@ -86,6 +88,19 @@ To build an image for MATLAB R2022b with Deep Learning Toolbox and Parallel Comp
8688
docker build --build-arg MATLAB_RELEASE=R2022b --build-arg ADDITIONAL_PRODUCTS="Deep_Learning_Toolbox Parallel_Computing_Toolbox" -t matlab_with_add_ons:R2022b .
8789
```
8890
For supported releases see [MATLAB Container Image on Docker Hub](https://hub.docker.com/r/mathworks/matlab).
91+
92+
### Build an Image with Modified Fonts Packages
93+
Use the `FONTS_PACKAGES` argument to build an image with a modified set of font packages. By default, it installs font support packages for a single locale (`ja_JP-UTF-8`). To override the default, specify other packages in the argument, for example, `fonts-arphic-gbsn00lp` (for Chinese) and `fonts-unfonts-core` (for Korean).
94+
```bash
95+
docker build --build-arg FONTS_PACKAGES="fonts-arphic-gbsn00lp fonts-unfonts-core" -t matlab_with_add_ons:R2025b .
96+
```
97+
98+
### Build an Image with Additional Ubuntu APT Packages
99+
Use the `ADDITIONAL_APT_PACKAGES` argument to build an image with additional Ubuntu APT packages. By default, it installs font support packages for various locales. To override the default, specify other packages in the argument, for example, `vim`.
100+
```bash
101+
docker build --build-arg ADDITIONAL_APT_PACKAGES="vim" -t matlab_with_add_ons:R2025b .
102+
```
103+
89104
### Build an Image with License Server Information
90105
If you include the license server information with the `docker build` command, you do not need to pass the information while running the container.
91106
To use this build argument, uncomment the corresponding lines in the Dockerfile.
@@ -94,7 +109,7 @@ server or the browser mode will not start successfully.
94109

95110
Build container with the license server.
96111
```bash
97-
docker build -t matlab_with_add_ons:R2025b --build-arg LICENSE_SERVER=27000@MyServerName .
112+
docker build --build-arg LICENSE_SERVER=27000@MyServerName -t matlab_with_add_ons:R2025b .
98113
```
99114

100115
Run the container, without needing to pass license information.
@@ -106,6 +121,16 @@ The Docker container you build using this Dockerfile inherits run options from i
106121
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.
107122
Run the commands provided in the instructions using the name of the Docker image that you build using this Dockerfile.
108123

124+
#### Set Custom Locale for Container
125+
126+
To set a custom locale for the MATLAB Docker container, install the appropriate fonts when building the Docker image. For example, use `fonts-vlgothic` for Japanese. These fonts are installed by default, unless you modify the `ADDITIONAL_APT_PACKAGES` argument.
127+
128+
After building the image, when you run the container, use the `-e` flag with the `LANG` environment variable to specify language and character encoding settings.
129+
130+
```bash
131+
docker run -it --rm -e LANG=ja_JP.UTF-8 --shm-size=512M matlab_with_add_ons:R2025b
132+
```
133+
109134
## More MATLAB Docker Resources
110135
For more resources, see [More MATLAB Docker Resources](https://github.com/mathworks-ref-arch/matlab-dockerfile#more-matlab-docker-resources).
111136

0 commit comments

Comments
 (0)