How can I pass data to a Docker container packaged with MATLAB Compiler?

2 次查看(过去 30 天)

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?

采纳的回答

MathWorks Support Team
There are several options for passing files, strings, secrets, etc. to a packaged Docker container.
  1. 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.
  2. 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.
  3. 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.
  4. 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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Containers 的更多信息

标签

尚未输入任何标签。

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by