- Input Argument - The simplest way to pass basic data like strings, is to take this data as an input argument for the function. Refer to the documentation for examples of how to package and run functions as Docker containers with input arguments.
- Mounted Volume - You can mount volumes to a container at runtime to make files available to the code within the container. See the Docker documentation for how to mount a volume. Note that the packaged code runs as a low-permission user in the container by default, so ensure the user specified by ContainerUser has access to any necessary files.
- Secrets - Sensitive strings, such as tokens or access keys, can be stored and accessed from your packaged code using MATLAB secrets. See the documentation for more details.
- Environment Variable - You can use the -e flag to pass environment variables to a Docker container at runtime. See the Docker documentation for more details.
How can I pass data to a Docker container packaged with MATLAB Compiler?
2 views (last 30 days)
Show older comments
MathWorks Support Team
on 30 Jun 2025
Answered: MathWorks Support Team
on 30 Jun 2025
I am using MATLAB Compiler to package a function as a Docker container. My function uses an access token to access files on the cloud, which works fine in base MATLAB. This token can be a string, environment variable, file, etc. as needed.
However, I don't know how to make this token string available to the function when it runs as a Docker container. How can I pass this data to my code?
Accepted Answer
MathWorks Support Team
on 30 Jun 2025
There are several options for passing files, strings, secrets, etc. to a packaged Docker container.
0 Comments
More Answers (0)
See Also
Categories
Find more on Containers 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!