Effacer les filtres
Effacer les filtres

Docker compose interactive Matlab license fail (infinite loop)

43 vues (au cours des 30 derniers jours)
Hud Bin
Hud Bin le 10 Avr 2024 à 21:40
Commenté : Hud Bin le 18 Avr 2024 à 23:25
Hello
I want to run a docker compose with 1 matlab container and 1 app container. Running the matlab container on its own works - it interactively prompts for username, I sign in on the browser and enter OTA license in the terminal and it connects. This is the dockerfile:
```
ARG MATLAB_RELEASE=R2023b
ARG ADDITIONAL_PRODUCTS="Simulink"
FROM mathworks/matlab:$MATLAB_RELEASE
ARG MATLAB_RELEASE
ARG ADDITIONAL_PRODUCTS
USER root
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install --no-install-recommends --yes \
wget \
unzip \
ca-certificates \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tmp
USER matlab
RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \
&& chmod +x mpm \
&& EXISTING_MATLAB_LOCATION=$(dirname $(dirname $(readlink -f $(which matlab)))) \
&& sudo HOME=${HOME} ./mpm install \
--destination=${EXISTING_MATLAB_LOCATION} \
--release=${MATLAB_RELEASE} \
--products ${ADDITIONAL_PRODUCTS} \
|| (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \
&& sudo rm -rf mpm /tmp/mathworks_root.log ${HOME}/.MathWorks
USER root
RUN apt-get update && apt-get install -y software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && apt-get install -y python3.9 python3-pip
RUN cd /opt/matlab/$MATLAB_RELEASE/extern/engines/python && \
python3 setup.py install
USER matlab
ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=$MW_CONTEXT_TAGS,MATLAB:TOOLBOXES:DOCKERFILE:V1
WORKDIR /home/matlab
```
However, when I run in as part of a docker compose, it prompts me for my password and it fails infinite times:
```
✔ Network dev_default Created 0.1s
✔ Container dev-matlab-1 Created 0.1s
✔ Container dev-app-1 Created 0.1s
Attaching to app-1, matlab-1
matlab-1 |
matlab-1 | Running matlab -licmode online
app-1 | python: can't open file '/app/app.py': [Errno 2] No such file or directory
matlab-1 | MATLAB is selecting SOFTWARE OPENGL rendering.
matlab-1 | Please enter your MathWorks Account email address and press Enter:
app-1 exited with code 0
app-1 exited with code 2
app-1 exited with code 2
app-1 exited with code 2
matlab-1 | Password input failed
matlab-1 | Would you like to retry? y/n [n]
matlab-1 | Please enter your MathWorks Account password and press Enter:
matlab-1 exited with code 0
app-1 exited with code 2
matlab-1 | MATLAB is selecting SOFTWARE OPENGL rendering.
matlab-1 | Please enter your MathWorks Account email address and press Enter:
app-1 exited with code 2
matlab-1 | Password input failed
matlab-1 | Would you like to retry? y/n [n]
matlab-1 | Please enter your MathWorks Account password and press Enter:
matlab-1 exited with code 0
matlab-1 | MATLAB is selecting SOFTWARE OPENGL rendering.
matlab-1 | Please enter your MathWorks Account email address and press Enter:
app-1 exited with code 2
matlab-1 | Password input failed
matlab-1 | Would you like to retry? y/n [n]
matlab-1 | Please enter your MathWorks Account password and press Enter:
matlab-1 exited with code 255
matlab-1 |
matlab-1 | Running matlab -licmode online
matlab-1 | MATLAB is selecting SOFTWARE OPENGL rendering.
matlab-1 | Please enter your MathWorks Account email address and press Enter:
matlab-1 | Please enter your MathWorks Account password and press Enter:
matlab-1 | Password input failed
matlab-1 | Would you like to retry? y/n [n]
matlab-1 exited with code 255
...
```
I am not able to download a license file. Is there any other way to solve this?
  2 commentaires
Prabhakar
Prabhakar le 11 Avr 2024 à 9:03
Can you share the docker compose file?
Hud Bin
Hud Bin le 11 Avr 2024 à 16:21
```
version: "3"
services:
matlab:
build:
context: .
dockerfile: matlab.Dockerfile
restart: always
app:
build:
context: .
dockerfile: dev.Dockerfile
ports:
- "80:80"
depends_on:
- matlab
restart: always
```

Connectez-vous pour commenter.

Réponses (1)

Prabhakar
Prabhakar le 14 Avr 2024 à 14:27
The issue here is with your docker compose file. It needs to be configured to notify the container to run in interactively.
# docker-compose.yml
version: "3"
services:
matlab:
image: mathworks/matlab:r2023b
stdin_open: true # docker run -i
tty: true # docker run -t
app:
image: nginx
ports:
- "81:80"
depends_on:
- matlab
restart: always
Then start the services using:
docker compose up -d
[+] Building 0.0s (0/0)
[+] Running 3/2
Network 2105411_default Created 0.1s
Container 2105411-matlab-1 Created 0.0s
Container 2105411-app-1 Created 0.0s
Finally, attach to the running matlab container using:
docker attach 2105411-matlab-1
Replace 2105411-matlab-1 with the name of the running container in your environment
When you are attached here, you will see an empty screen because the text prompting you for the email address was already printed before you could attach.
To continue, enter your email address and follow the prompts as shown below:
docker attach 2105411-matlab-1
your-email-address@mathworks.com
Single-Sign-On(SSO) is not available in this environment. You need a one-time password to sign in to MATLAB.
Step 1. Visit https://www.mathworks.com/mwa/otp
Step 2. Copy the password.
Step 3. Return here, and input the password.
Please enter the one-time password:
377669
Starting MATLAB with license: 4044XXXX - MATLAB - Staff Use
< M A T L A B (R) >
Copyright 1984-2023 The MathWorks, Inc.
R2023b Update 6 (23.2.0.2485118) 64-bit (glnxa64)
December 28, 2023
To get started, type doc.
For product information, visit www.mathworks.com.
>>
To avoid the empty screen when you attach to the matlab container you could update the entrypoint in the docker compose file to /usr/bin/bash so that when you attach into the container, you will be presented with a BASH prompt. There you could execute the default entrypoint for the mathworks/matlab container ie: run.sh
# docker-compose.yml
version: "3"
services:
matlab:
image: mathworks/matlab:r2023b
entrypoint: /usr/bin/bash
stdin_open: true # docker run -i
tty: true # docker run -t
app:
image: nginx
ports:
- "81:80"
depends_on:
- matlab
restart: always
Start the services in detached mode:
docker compose -d
[+] Building 0.0s (0/0)
[+] Running 3/3
Network 2105411_default Created 0.1s
Container 2105411-matlab-1 Started 0.8s
Container 2105411-app-1 Started 1.4s
Attach to the matlab container
docker attach 2105411-matlab-1
matlab@35ded52975da:~/Documents/MATLAB$ run.sh
Running matlab -licmode online
MATLAB is selecting SOFTWARE OPENGL rendering.
Please enter your MathWorks Account email address and press Enter:
Hope this helps!
  1 commentaire
Hud Bin
Hud Bin le 18 Avr 2024 à 23:25
Thank you @Prabhakar - I kinda solved it by interactively authenticating via the web and committing to a new docker container image

Connectez-vous pour commenter.

Catégories

En savoir plus sur Containers dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by