Skip to content

Commit 6fbaaf8

Browse files
michaelmcdonnellmwprabhakk-mw
authored andcommitted
Add the ability to specify the base OS version with a build arg.
fixes #146
1 parent b769883 commit 6fbaaf8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox"
99
# --build-arg MATLAB_INSTALL_LOCATION="/opt/matlab/R2025b"
1010
# --build-arg LICENSE_SERVER=12345@hostname.com
11+
# --build-arg UBUNTU_VERSION=24.04
1112
# -t my_matlab_image_name .
1213

1314
# To specify which MATLAB release to install in the container, edit the value of the MATLAB_RELEASE argument.
@@ -20,12 +21,15 @@ ARG MATLAB_PRODUCT_LIST="MATLAB"
2021
# Specify MATLAB Install Location.
2122
ARG MATLAB_INSTALL_LOCATION="/opt/matlab/${MATLAB_RELEASE}"
2223

24+
# Specify a ubuntu version to use for the container
25+
ARG UBUNTU_VERSION
26+
2327
# Specify license server information using the format: port@hostname
2428
ARG LICENSE_SERVER
2529

2630
# When you start the build stage, this Dockerfile by default uses the Ubuntu-based matlab-deps image.
2731
# To check the available matlab-deps images, see: https://hub.docker.com/r/mathworks/matlab-deps
28-
FROM mathworks/matlab-deps:${MATLAB_RELEASE}
32+
FROM mathworks/matlab-deps:${MATLAB_RELEASE}${UBUNTU_VERSION:+-ubuntu${UBUNTU_VERSION}}
2933

3034
# Declare build arguments to use at the current build stage.
3135
ARG MATLAB_RELEASE

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/ma
6868
| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | R2025b | MATLAB release to install, for example, `R2023b`.|
6969
| [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).|
7070
| [MATLAB_INSTALL_LOCATION](#build-an-image-with-matlab-installed-to-a-specific-location) | /opt/matlab/R2025b | Path to install MATLAB. |
71+
| [UBUNTU_VERSION](#build-an-image-based-on-a-specific-os) | *unset* | The base OS that should be used to build on top of. For example: 24.04|
7172
| [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` |
7273

7374
Use these arguments with the `docker build` command to customize your image.
@@ -91,6 +92,15 @@ For example, to build an image with MATLAB installed at /opt/matlab, use this co
9192
docker build --build-arg MATLAB_INSTALL_LOCATION='/opt/matlab' -t matlab:R2025b .
9293
```
9394

95+
#### Build an Image Based on a Specific OS
96+
97+
You can specify a base OS image to build upon using the `UBUNTU_VERSION` build argument. These should follow th convention used for the `mathworks/matlab-deps` images. For more information see the [list of matlab-deps base images](https://hub.docker.com/r/mathworks/matlab-deps#supported-tags). For example:
98+
99+
```bash
100+
# Build a container based on a specific OS.
101+
docker build --build-arg UBUNTU_VERSION=24.04 -t matlab:R2025a .
102+
```
103+
94104
#### Build an Image Configured to Use a License Server
95105

96106
Including the license server information with the `docker build` command means you do not have to pass it when running the container.

0 commit comments

Comments
 (0)