Skip to content

Commit 7314af2

Browse files
committed
One more
1 parent e97d61b commit 7314af2

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Configure Container Create Options for Azure IoT Edge Modules
33
description: Configure IoT Edge modules with Docker-compatible create options for tasks like port mapping, memory limits, and GPU optimization.
44
author: sethmanheim
55
ms.author: sethm
6-
ms.date: 05/09/2025
6+
ms.date: 03/05/2026
77
ms.topic: concept-article
88
ms.service: azure-iot-edge
99
services: iot-edge
@@ -19,7 +19,7 @@ ms.custom:
1919

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

22-
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.
22+
Use the `createOptions` parameter in the deployment manifest to configure the module containers at runtime. By using this parameter, you can restrict the module's access to the host device's resources or configure networking.
2323

2424
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/reference/cli/docker/container/create/).
2525

@@ -51,7 +51,7 @@ The IoT Edge deployment manifest accepts create options formatted as JSON. For e
5151
}
5252
```
5353

54-
This edgeHub example uses the **HostConfig.PortBindings** parameter to map exposed ports on the container to a port on the host device.
54+
This **edgeHub** example uses the `HostConfig.PortBindings` parameter to map exposed ports on the container to a port on the host device.
5555

5656
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:
5757

@@ -60,11 +60,11 @@ If you use the [Azure IoT Edge](https://marketplace.visualstudio.com/items?itemN
6060
```
6161

6262
> [!IMPORTANT]
63-
> 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.
63+
> 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.
6464
65-
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:
65+
Use the `docker inspect` command to write create options. Run the module locally by using `docker run <container name>` as part of your development process. Once you have the module working the way you want, 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:
6666

67-
:::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":::
67+
:::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":::
6868

6969
## Common scenarios
7070

@@ -77,14 +77,14 @@ Container create options support various scenarios. Here are the most common one
7777

7878
### Map host port to module port
7979

80-
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.
80+
If your module needs to communicate with a service outside of the IoT Edge solution and isn't using message routing to do so, map a host port to a module port.
8181

82-
>[!TIP]
83-
>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`.
82+
> [!TIP]
83+
> 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, it exposes `EXPOSE 8080`. Then, module A can query the API using module B's name; for example, `http://ModuleB:8080/api`.
8484
85-
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.
85+
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 the TCP protocol if you don't specify a protocol, or you can specify UDP.
8686

87-
Then, use the **PortBindings** setting in the **HostConfig** group of the [Docker container create options](https://docs.docker.com/reference/cli/docker/container/create/) 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:
87+
Then, use the `PortBindings` setting in the `HostConfig` group of the [Docker container create options](https://docs.docker.com/reference/cli/docker/container/create/) 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 port to port 80 on the host device, the create options in the template.json file would look like the following example:
8888

8989
```json
9090
"createOptions": {
@@ -108,13 +108,13 @@ When stringified for the deployment manifest, the configuration looks like this:
108108

109109
### Restrict module memory and CPU usage
110110

111-
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/reference/cli/docker/container/create/) in the **HostConfig** group, including:
111+
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 using the [Docker container create options](https://docs.docker.com/reference/cli/docker/container/create/) in the `HostConfig` group, including:
112112

113113
* **Memory**: Memory limit in bytes. For example, 268435456 bytes = 256 MB.
114114
* **MemorySwap**: Total memory limit (memory + swap). For example, 536870912 bytes = 512 MB.
115115
* **NanoCpus**: CPU quota in units of 10<sup>-9</sup> (1 billionth) CPUs. For example, 250000000 nanocpus = 0.25 CPU.
116116

117-
In the template.json format, these values would look like the following example:
117+
In the **template.json** format, these values look like the following example:
118118

119119
```json
120120
"createOptions": {
@@ -126,21 +126,21 @@ In the template.json format, these values would look like the following example:
126126
}
127127
```
128128

129-
Once stringified for the final deployment manifest, these values would look like the following example:
129+
Once stringified for the final deployment manifest, these values look like the following example:
130130

131131
```json
132132
"createOptions":"{\"HostConfig\":{\"Memory\":268435456,\"MemorySwap\":536870912,\"NanoCpus\":250000000}}"
133133
```
134134

135135
### GPU-optimize an IoT Edge module
136136

137-
If you're running your IoT Edge module on a GPU-optimized virtual machine, you can enable an IoT Edge module to connect to your GPU as well. To do this with an existing module, add some specifications to your `createOptions`:
137+
If you run your IoT Edge module on a GPU-optimized virtual machine, you can enable an IoT Edge module to connect to your GPU as well. To do this connection using an existing module, add some specifications to your `createOptions`:
138138

139139
```json
140140
{"HostConfig": {"DeviceRequests": [{"Count": -1,"Capabilities": [["gpu"]]}]}}
141141
```
142142

143-
Confirm these settings by using the Docker inspect command to view the new setting in a JSON printout.
143+
Confirm these settings by using the Docker `inspect` command to view the new setting in a JSON printout:
144144

145145
```bash
146146
sudo docker inspect <YOUR-MODULE-NAME>

0 commit comments

Comments
 (0)