Skip to content

Commit 09feb66

Browse files
Merge pull request #299603 from PatAltimore/patricka-freshness
Freshness review
2 parents d3fdbd2 + f9c7b44 commit 09feb66

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

articles/iot-edge/how-to-use-create-options.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
---
2-
title: Write createOptions for modules - Azure IoT Edge | Microsoft Docs
3-
description: How to use createOptions in the deployment manifest to configure modules at runtime
2+
title: Configure Container Create Options for Azure IoT Edge Modules
3+
description: Configure IoT Edge modules with Docker-compatible create options for tasks like port mapping, memory limits, and GPU optimization.
44
author: PatAltimore
55
ms.author: patricka
6-
ms.date: 04/01/2020
7-
ms.topic: conceptual
6+
ms.date: 05/09/2025
7+
ms.topic: concept-article
88
ms.service: azure-iot-edge
99
services: iot-edge
10+
ms.custom:
11+
- ai-gen-docs-bap
12+
- ai-gen-title
13+
- ai-seo-date:05/09/2025
14+
- ai-gen-description
1015
---
1116

1217
# How to configure container create options for IoT Edge modules
1318

1419
[!INCLUDE [iot-edge-version-all-supported](includes/iot-edge-version-all-supported.md)]
1520

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.
21+
The **createOptions** parameter in the deployment manifest lets you configure the module containers at runtime. This parameter expands your control over the modules and lets you perform tasks like restricting the module's access to the host device's resources or configuring networking.
1722

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).
23+
IoT Edge modules run as Docker-compatible containers on your IoT Edge device. Docker offers many options for creating containers, and those options also apply to IoT Edge modules. For more information, see [Docker container create options](https://docs.docker.com/engine/api/v1.32/#operation/ContainerCreate).
1924

2025
## Format create options
2126

@@ -47,7 +52,7 @@ The IoT Edge deployment manifest accepts create options formatted as JSON. For e
4752

4853
This edgeHub example uses the **HostConfig.PortBindings** parameter to map exposed ports on the container to a port on the host device.
4954

50-
If you use the [Azure IoT Edge](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-edge) extension for Visual Studio or Visual Studio Code, you can write the create options in JSON format in the **deployment.template.json** file. Then, when you use the extension to build the IoT Edge solution or generate the deployment manifest, it will stringify the JSON for you in the format that the IoT Edge runtime expects. For example:
55+
If you use the [Azure IoT Edge](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-edge) extension for Visual Studio or Visual Studio Code, write the create options in JSON format in the **deployment.template.json** file. Then, when you use the extension to build the IoT Edge solution or generate the deployment manifest, it stringifies the JSON in the format that the IoT Edge runtime expects. For example:
5156

5257
```json
5358
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}"
@@ -56,13 +61,13 @@ If you use the [Azure IoT Edge](https://marketplace.visualstudio.com/items?itemN
5661
> [!IMPORTANT]
5762
> The Azure IoT Edge Visual Studio Code extension is in [maintenance mode](https://github.com/microsoft/vscode-azure-iot-edge/issues/639). The *iotedgedev* tool is the recommended tool for developing IoT Edge modules.
5863
59-
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:
64+
Use the `docker inspect` command to write create options. Run the module locally using `docker run <container name>` as part of your development process. 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 you configured and copy the JSON. For example:
6065

61-
:::image type="content" source="./media/how-to-use-create-options/docker-inspect-edgehub-inline-and-expanded.png" alt-text="Screenshot of the results of the command docker inspect edgeHub." lightbox="./media/how-to-use-create-options/docker-inspect-edgehub-inline-and-expanded.png":::
66+
:::image type="content" source="./media/how-to-use-create-options/docker-inspect-edgehub-inline-and-expanded.png" alt-text="Screenshot of the results of the `docker inspect edgeHub` command." lightbox="./media/how-to-use-create-options/docker-inspect-edgehub-inline-and-expanded.png":::
6267

6368
## Common scenarios
6469

65-
Container create options enable many scenarios, but here are some that come up most often when building IoT Edge solutions:
70+
Container create options support various scenarios. Here are the most common ones for building IoT Edge solutions:
6671

6772
* [Give modules access to host storage](how-to-access-host-storage-from-module.md)
6873
* [Map host port to module port](#map-host-port-to-module-port)
@@ -74,9 +79,9 @@ Container create options enable many scenarios, but here are some that come up m
7479
If your module needs to communicate with a service outside of the IoT Edge solution, and isn't using message routing to do so, then you need to map a host port to a module port.
7580

7681
>[!TIP]
77-
>This port mapping is not required for module-to-module communication on the same device. If module A needs to query an API hosted on module B, it can do so without any port mapping. Module B needs to expose a port in its dockerfile, for example: `EXPOSE 8080`. Then module A can query the API using module B's name, for example: `http://ModuleB:8080/api`.
82+
>Port mapping isn't required for module-to-module communication on the same device. If module A needs to query an API hosted on module B, it can do so without any port mapping. Module B needs to expose a port in its dockerfile. For example, `EXPOSE 8080`. Then, module A can query the API using module B's name. For example, `http://ModuleB:8080/api`.
7883
79-
First, make sure that a port inside the module is exposed to listen for connections. You can do this using an [EXPOSE](https://docs.docker.com/engine/reference/builder/#expose) instruction in the dockerfile. For example, `EXPOSE 8080`. The expose instruction defaults to TCP protocol if not specified, or you can specify UDP.
84+
First, ensure that a port inside the module is exposed to listen for connections. You can do this using an [EXPOSE](https://docs.docker.com/engine/reference/builder/#expose) instruction in the dockerfile. For example, `EXPOSE 8080`. The expose instruction defaults to TCP protocol if not specified, or you can specify UDP.
8085

8186
Then, use the **PortBindings** setting in the **HostConfig** group of the [Docker container create options](https://docs.docker.com/engine/api/v1.32/#operation/ContainerCreate) to map the exposed port in the module to a port on the host device. For example, if you exposed port 8080 inside the module and want to map that to port 80 of the host device, the create options in the template.json file would look like the following example:
8287

@@ -94,15 +99,15 @@ Then, use the **PortBindings** setting in the **HostConfig** group of the [Docke
9499
}
95100
```
96101

97-
Once stringified for the deployment manifest, the same configuration would look like the following example:
102+
When stringified for the deployment manifest, the configuration looks like this:
98103

99104
```json
100105
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"8080/tcp\":[{\"HostPort\":\"80\"}]}}}"
101106
```
102107

103108
### Restrict module memory and CPU usage
104109

105-
You can declare how much of the host resources a module can use. This control is helpful to ensure that one module can't consume too much memory or CPU usage and prevent other processes from running on the device. You can manage these settings with [Docker container create options](https://docs.docker.com/engine/api/v1.32/#operation/ContainerCreate) in the **HostConfig** group, including:
110+
Declare how much of the host resources a module can use. This control ensures that one module doesn't consume too much memory or CPU, preventing other processes from running on the device. You can manage these settings with [Docker container create options](https://docs.docker.com/engine/api/v1.32/#operation/ContainerCreate) in the **HostConfig** group, including:
106111

107112
* **Memory**: Memory limit in bytes. For example, 268435456 bytes = 256 MB.
108113
* **MemorySwap**: Total memory limit (memory + swap). For example, 536870912 bytes = 512 MB.
@@ -134,7 +139,7 @@ If you're running your IoT Edge module on a GPU-optimized virtual machine, you c
134139
{"HostConfig": {"DeviceRequests": [{"Count": -1,"Capabilities": [["gpu"]]}]}}
135140
```
136141

137-
To confirm these settings were successfully added, use the Docker inspect command to see the new setting in a JSON printout.
142+
Confirm these settings by using the Docker inspect command to view the new setting in a JSON printout.
138143

139144
```bash
140145
sudo docker inspect <YOUR-MODULE-NAME>
@@ -144,7 +149,7 @@ To learn more about how your device and virtual machine connect to a GPU, see [C
144149

145150
## Next steps
146151

147-
For more examples of create options in action, see the following IoT Edge samples:
152+
For more examples of create options in action, see these IoT Edge samples:
148153

149154
* [Custom Vision and Azure IoT Edge on a Raspberry Pi 3](https://github.com/Azure-Samples/custom-vision-service-iot-edge-raspberry-pi)
150155
* [Azure IoT Edge blob storage sample](https://github.com/Azure-Samples/azure-iotedge-blobstorage-sample)

0 commit comments

Comments
 (0)