MATLAB docker-compose.yml configuration
11 views (last 30 days)
Show older comments
I'm trying to dockerize MATLAB with other services (React JS, Python Django, and Postgres database - these other services have been successfully dockerized and integrated).
When I run docker-compose up, it hangs on building the matlab image. I followed steps 1-4 (for step 2, I used the MATLAB Linux ISO image for MATLAB R2020b) for the Dockerfile for MATLAB: https://github.com/mathworks-ref-arch/matlab-dockerfile#optional-dependencies
I did not build the docker image (step 5) though as I need it to be built along with my other services. I noticed step 5 though requiresa a few parameters:
docker build -t matlab:r2020a --build-arg LICENSE_SERVER=27000@MyServerName .
What should the license server parameters be and how should I include them in the docker-compose.yml if necessary?
I copied the whole repository matlab-dockerfile afterwards to ./back-end/server_side/send_values/api/matlab/ (relative path on my MacOS system). The Dockerfile is in ./back-end/server_side/send_values/api/matlab/ and is the same Dockerfile at https://github.com/mathworks-ref-arch/matlab-dockerfile#optional-dependencies
How should I update the docker-compose.yml file to correctly build the MATLAB image?
docker-compose.yml
version: "3.9"
services:
db:
image: postgres
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
matlab:
build: ./back-end/server_side/send_values/api/matlab/matlab-dockerfile
backend:
build: ./back-end
command: python server_side/manage.py runserver 0.0.0.0:8000
volumes:
- ./back-end:/code
environment:
- SECRET_KEY=${SECRET_KEY:?err}
- DEBUG=${DEBUG}
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- DB_HOST=${DB_HOST}
- DB_PORT=${DB_PORT}
ports:
- "8000:8000"
depends_on:
- db
- matlab
frontend:
build: ./react-ui
command: npm start
volumes:
- ./react-ui:/app
# Don't want to use local node modules
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
- /app/node_modules/
ports:
- "3000:3000"
depends_on:
- backend
1 Comment
Yash Patel
on 24 Apr 2024
Hey Aditya, were you able to get around this? I am trying to build an airflow data pipeline wherein I use a lot matlab for neuroimaging computations. Considering I am dealing with multiple containers i.e. Airflow and matlab I am currently orchestrating it with docker-compose but the issue I run into is that when i run docker-compose up it spins up the containers but matlab fails because it asks for a user email id and password which I can't provide as it is a multi-container setup. Further because I want to run neuroimaging stuff I need certain toolboxes which I hope you can help me figure out how to get them into this container. I'm sure I'm not first one having multi-container setups, is there a way to get the license sorted for this. I think my account has the necessary license to run this.
Answers (1)
Swastik Sarkar
on 1 Aug 2024
It seems that you are attempting to build MATLAB as a service using Docker Compose. The method you are currently trying might require interaction if you do not have a network license server set up. To avoid this, I recommend using the "non-interactive" workflow with a MATLAB Batch Licensing Token.
This method is designed for scenarios where interaction is not feasible, such as in CI/CD pipelines or automated deployments. You can find more information about this method here:
Follow the instructions provided in the MATLAB Dockerfile repository to create a container image suited for non-interactive workflows. Detailed steps are available here:
Hope this helps.
0 Comments
See Also
Categories
Find more on Manage Products in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!