You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-edge/how-to-use-create-options.md
+2-46Lines changed: 2 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ services: iot-edge
13
13
14
14
# How to configure container create options for IoT Edge modules
15
15
16
-
The **createOptions** parameter in the deployment manifest enables you to configure the module containers at runtime. This parameter expands your control over the modules and allows for tasks like passing environment variables to the module, allowing or restricting the module's access to the host device's resources, or configuring networking.
16
+
The **createOptions** parameter in the deployment manifest enables you to configure the module containers at runtime. This parameter expands your control over the modules and allows for tasks like allowing or restricting the module's access to the host device's resources, or configuring networking.
17
17
18
18
IoT Edge modules are implemented as Docker-compatible containers on your IoT Edge device. Docker offers many options for creating containers, and those options apply to IoT Edge modules, too. For more information, see [Docker container create options](https://docs.docker.com/engine/api/v1.32/#operation/ContainerCreate).
19
19
@@ -53,7 +53,7 @@ If you use the Azure IoT Tools extensions for Visual Studio or Visual Studio Cod
Another tip for formatting createOptions is to use the `docker inspect` command. As part of your development process, run the module locally using `docker run <container name>`. Once you have the module working the way you want it, run `docker inspect <container name>`. This command outputs the module details in JSON format. Find the parameters that you configured, and copy the JSON formatting. For example:
56
+
One tip for writing create options is to use the `docker inspect` command. As part of your development process, run the module locally using `docker run <container name>`. Once you have the module working the way you want it, run `docker inspect <container name>`. This command outputs the module details in JSON format. Find the parameters that you configured, and copy the JSON. For example:
57
57
58
58

59
59
@@ -64,7 +64,6 @@ Container create options enable many scenarios, but here are some that come up m
64
64
*[Give modules access to host storage](how-to-access-host-storage-from-module.md)
65
65
*[Map host port to module port](#map-host-port-to-module-port)
66
66
*[Restrict module memory and CPU usage](#restrict-module-memory-and-cpu-usage)
67
-
*[Create environment variables in modules](#create-environment-variables-in-modules)
68
67
69
68
### Map host port to module port
70
69
@@ -123,49 +122,6 @@ Once stringified for the final deployment manifest, these values would look like
If you need to pass variables to your modules at runtime, you can create environment variables inside the module using the create options. These variables can be called from the module using an operating system get environment command. You can declare environment variables using the **Env** setting in the [Docker container create options](https://docs.docker.com/engine/api/v1.32/#operation/ContainerCreate).
129
-
130
-
In the template.json format, an environment variable is declared with the following example:
131
-
132
-
```json
133
-
"createOptions": {
134
-
"Env": [
135
-
"variable1=100",
136
-
"variable2=200"
137
-
]
138
-
}
139
-
```
140
-
141
-
Once stringified for the final deployment manifest, these values would look like the following example:
>You can pass environment variables to a module in two locations in the deployment manifest. The first is in the create options, and the second is as part of the module definition. For example:
149
-
>
150
-
>```json
151
-
>"modules": {
152
-
> "moduleA": {
153
-
> "version": "1.0",
154
-
> "type": "docker",
155
-
> "status": "running",
156
-
> "restartPolicy": "always",
157
-
> "env": {
158
-
> "variable1": {"value": "100"},
159
-
> "variable2": {"value": "200"},
160
-
> },
161
-
> "settings": {
162
-
> "image": "${MODULES.moduleA.arm32v7}",
163
-
> "createOptions": { }
164
-
> }
165
-
> }
166
-
>}
167
-
>```
168
-
169
125
## Next steps
170
126
171
127
For more examples of create options in action, see the following IoT Edge samples:
| modules.{moduleId}.imagePullPolicy | {"on-create" \| "never"} | No |
53
+
| modules.{moduleId}.env | A list of environment variables to pass to the module. Takes the format `"<name>": {"value": "<value>"}`| No |
53
54
| modules.{moduleId}.settings.image | The URI to the module image. | Yes |
54
55
| modules.{moduleId}.settings.createOptions | A stringified JSON containing the options for the creation of the module container. [Docker create options](https://docs.docker.com/engine/api/v1.32/#operation/ContainerCreate)| No |
55
56
| modules.{moduleId}.configuration.id | The ID of the deployment that deployed this module. | IoT Hub sets this property when the manifest is applied using a deployment. Not part of a deployment manifest. |
0 commit comments