Skip to content

Commit b89b33e

Browse files
Updates the non-interactive container to use tini rather than requiring --init
1 parent 577e541 commit b89b33e

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

alternates/non-interactive/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024-2025 The MathWorks, Inc.
1+
# Copyright 2024-2026 The MathWorks, Inc.
22
# This Dockerfile allows you to build a Docker® image with MATLAB® installed using the MATLAB Package
33
# Manager and licensed using MATLAB Batch Licensing. Use the optional build arguments to customize the
44
# version of MATLAB, list of products to install, and the location at which to install MATLAB.
@@ -28,13 +28,14 @@ ARG MATLAB_RELEASE
2828
ARG MATLAB_PRODUCT_LIST
2929
ARG MATLAB_INSTALL_LOCATION
3030

31-
# Install mpm dependencies.
31+
# Install mpm dependencies along with those required to run matlab-batch within the container.
3232
RUN export DEBIAN_FRONTEND=noninteractive \
3333
&& apt-get update \
3434
&& apt-get install --no-install-recommends --yes \
3535
wget \
3636
ca-certificates \
3737
xvfb \
38+
tini \
3839
&& apt-get clean \
3940
&& apt-get autoremove \
4041
&& rm -rf /var/lib/apt/lists/*
@@ -74,5 +75,5 @@ RUN wget -q 'https://raw.githubusercontent.com/mathworks-ref-arch/matlab-dockerf
7475
# https://github.com/mathworks-ref-arch/matlab-dockerfile#help-make-matlab-even-better
7576
ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=MATLAB:BATCHLICENSING:DOCKERFILE:V1
7677

77-
ENTRYPOINT ["xvfb-run"]
78+
ENTRYPOINT ["tini", "--", "xvfb-run"]
7879
CMD ["/bin/bash"]

alternates/non-interactive/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Build a container with a name and tag.
2828
docker build -t matlab-non-interactive:R2025b .
2929
```
3030

31-
You can then run the container and use the `matlab-batch` command. Test the container by running an example MATLAB command, such as `rand`. 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.
31+
You can then run the container and use the `matlab-batch` command. Test the container by running an example MATLAB command, such as `rand`.
3232

3333
```bash
34-
docker run --init --rm matlab-non-interactive:R2025b matlab-batch -licenseToken "user@email.com::encodedToken" "rand"
34+
docker run --rm matlab-non-interactive:R2025b matlab-batch -licenseToken "user@email.com::encodedToken" "rand"
3535
```
3636
For more information, see [Run the Container](#run-the-container).
3737

@@ -86,22 +86,22 @@ With the `docker run` command, use one of these options.
8686
- Specify the `-licenseToken` run-arg.
8787
```bash
8888
# Example
89-
docker run --init --rm matlab-non-interactive:R2025b matlab-batch -licenseToken "user@email.com::encodedToken" "disp('Hello, World.')"
89+
docker run --rm matlab-non-interactive:R2025b matlab-batch -licenseToken "user@email.com::encodedToken" "disp('Hello, World.')"
9090
```
9191

9292
- Specify the `MLM_LICENSE_TOKEN` environment variable.
9393
```bash
9494
# Example
9595
export MLM_LICENSE_TOKEN="user@email.com::encodedToken"
96-
docker run --init --rm -e MLM_LICENSE_TOKEN matlab-non-interactive:R2025b matlab-batch "disp('Hello, World.')"
96+
docker run --rm -e MLM_LICENSE_TOKEN matlab-non-interactive:R2025b matlab-batch "disp('Hello, World.')"
9797
```
9898

9999
## Run the Container
100100
This Dockerfile's default entry-point is a shell session. After you start the container, use `matlab-batch` to start MATLAB with a MATLAB batch licensing token.
101101
102102
```bash
103103
# Launch MATLAB, print Hello, World., and exit:
104-
docker run --init --rm matlab-non-interactive:R2025b matlab-batch -licenseToken "user@email.com::encodedToken" "disp('Hello, World.')"
104+
docker run --rm matlab-non-interactive:R2025b matlab-batch -licenseToken "user@email.com::encodedToken" "disp('Hello, World.')"
105105
```
106106
107107
You can set your MATLAB batch licensing token at the container level by setting the `MLM_LICENSE_TOKEN` environment variable, as shown in the examples below.
@@ -111,15 +111,15 @@ To start the container, run a MATLAB command and exit, use this command.
111111
```bash
112112
# Container runs the command RAND in MATLAB and exits.
113113
export MLM_LICENSE_TOKEN="user@email.com::encodedToken"
114-
docker run --init --rm -e MLM_LICENSE_TOKEN matlab-non-interactive:R2025b matlab-batch rand
114+
docker run --rm -e MLM_LICENSE_TOKEN matlab-non-interactive:R2025b matlab-batch rand
115115
```
116116
117117
### Run a MATLAB script
118118
To start the container, run a MATLAB script and exit, use this command.
119119
```bash
120120
# Container runs the script myscript.m in MATLAB and exits.
121121
export MLM_LICENSE_TOKEN="user@email.com::encodedToken"
122-
docker run --init --rm -v $(pwd):/content -w /content -e MLM_LICENSE_TOKEN matlab-non-interactive:R2025b matlab-batch "myscript"
122+
docker run --rm -v $(pwd):/content -w /content -e MLM_LICENSE_TOKEN matlab-non-interactive:R2025b matlab-batch "myscript"
123123
```
124124
125125
## More MATLAB Docker Resources
@@ -137,4 +137,4 @@ To learn more, see the documentation: [Help Make MATLAB Even Better - Frequently
137137
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).
138138
139139
---
140-
Copyright 2024-2025 The MathWorks, Inc.
140+
Copyright 2024-2026 The MathWorks, Inc.

tests/alternates/non-interactive/test_matlabbatch_display.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks, Inc.
1+
# Copyright 2024-2026 The MathWorks, Inc.
22

33
"""
44
Test class to validate the non-interactive dockerfile.
@@ -40,7 +40,7 @@ def test_display_workflow(self):
4040
runDisplayTest will run some example tests that require a display.
4141
This is equivalent to running
4242
43-
docker run --init -it --rm -e MLM_LICENSE_TOKEN=... non-interactive:r2024a matlab-batch runDisplayTest
43+
docker run -it --rm -e MLM_LICENSE_TOKEN=... non-interactive:r2024a matlab-batch runDisplayTest
4444
"""
4545
cmd = "matlab-batch runDisplayTest"
4646
mtest_file_name = "runDisplayTest.m"
@@ -56,7 +56,6 @@ def test_display_workflow(self):
5656

5757
self.container = self.client.containers.run(
5858
image=self.image_name,
59-
init=True,
6059
detach=True,
6160
stdin_open=True,
6261
environment={"MLM_LICENSE_TOKEN": os.getenv("BATCH_TOKEN")},

0 commit comments

Comments
 (0)