How to set hostname of container provisioned through IoTEdge

Brian B. Jensen 5 Reputation points
2024-07-10T12:13:37.2733333+00:00

I am running an instance of RabbitMQ on my edge devices and want to persist data between deployments.

A common practice to persist data across deployments is to map a directory from the host, into a directory where the service is saving / backing up data to disk. In the case of RabbitMQ, this is dependent on the hostname of the docker container. To get around this issue, one has to set the hostname of the instance as described in this article:

https://www.futurefundamentals.com/set-rabbitmq-with-data-persistent-with-docker-compose/

The IoT Edge documentation suggests to use information found by inspecting the docker container and copy parts of this into the deployment.template.json file for IoT Edge to apply to a container in deployment:

https://learn.microsoft.com/en-us/azure/iot-edge/how-to-use-create-options?view=iotedge-1.5

However, it does not describe how to set the hostname of a docker container that will be deployed.

I have tried a few different configurations like the one pasted below, to see if I could magically just set the hostname, but without succes.

User's image

I expect to be able to solve this issue by making a script that looks for a preexisting folder-structure in the data folder of RabbitMQ and then renames to fit the current hostname, but I would prefer the more elegant solution of just setting the hostname of the docker instance.

Thanks in advance! :-)

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
558 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Brian B. Jensen 5 Reputation points
    2024-07-10T14:16:21.79+00:00

    According to Docker's documentation (https://docs.docker.com/engine/api/v1.32/#tag/Container/operation/ContainerCreate) it is possible to pass the key "Hostname" on the same level as "HostConfig" so I tried this:

    User's image

    Which seems to have solved my issue:
    User's image

    1 person found this answer helpful.