How to deploy hub.docker.com container to IoT Edge device with Visual Studi Code?

CARLOS ARTURO TAMAYO MOJICA 0 Reputation points
2023-02-28T16:49:39.7766667+00:00

I can't find docs form learn.microsoft.com, Thank you for your help.

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.
530 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,112 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Sander van de Velde 28,161 Reputation points MVP
    2023-02-28T19:03:16.69+00:00

    Hello @CARLOS ARTURO TAMAYO MOJICA,

    containers put in Docker hub are supported by Azure IoT Edge.

    I expect you are already familiar with Azure IoT Edge and the deployment manifest.

    As with every container, you need to provide the name (and tag) in the Deployment manifest.

    Here is an example of public container:

    User's image

    As you can see, I provide the docker hub account name along the container identification

    This is almost the same as an original pull request:

    docker pull svelde/iot-edge-tradfri:0.5.21-windows-amd64
    

    If your container is made private in Docker Hub, you need to provide credentials to your private repository:

    User's image

    I expect the address is hub.docker.com and the username is your account name.

    Regarding the password you could use your own password but I expect you need to create an access token if you want to be more flexible/secure.

    User's image

    -

    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    1 person found this answer helpful.

  2. QuantumCache 20,026 Reputation points
    2023-03-01T22:46:09.7933333+00:00
    1 person found this answer helpful.
    0 comments No comments

  3. QuantumCache 20,026 Reputation points
    2023-03-01T22:45:41.37+00:00

    Hello CARLOS ARTURO TAMAYO MOJICA,

    I hope the following quick information will guide you with the initial query...

    • Install the Azure IoT Edge extension for Visual Studio Code:
    • Set up your Azure IoT Hub and Edge device:
    • Create a deployment manifest:

    Deploy Azure IoT Edge modules from Visual Studio Code

    During the configure manifest step, you want to give the hub.docker.com address!

    Configure a deployment manifest

    {
        "modules": {
            "my_module": {
                "version": "1.0",
                "type": "docker",
                "status": "running",
                "restartPolicy": "always",
                "settings": {
                    "image": "dockerhubusername/dockerhubimagename:tag",
                    "createOptions": {}
                }
            }
        }
    }
    
    

    Replace "my_module", "dockerhubusername/dockerhubimagename:tag" with your preferred module and container image name and tag.

    User's image

    • Build and deploy the deployment manifest:

    Also check the below info:

    • Select the IoT Edge device and create a new file named docker-creds.json.
    • In the file, enter the following JSON object with the Docker Hub registry URL and credentials:
    {
        "docker": {
            "registry": "https://index.docker.io/v1/",
            "username": "<your docker hub username>",
            "password": "<your docker hub password>"
        }
    }
    
    
    1. Replace <your docker hub username> and <your docker hub password> with your Docker Hub account credentials.
    2. Update the deployment manifest file:
      • Open the deployment manifest file (deployment.template.json) and add a new module with the container image from Docker Hub, using the following format:
        "module_name": {
            "version": "1.0",
            "type": "docker",
            "status": "running",
            "restartPolicy": "always",
            "settings": {
                "image": "docker.io/<username>/<image_name>:<tag>",
                "registryCredentials": {
                    "server": "docker.io",
                    "username": "$CONTAINER_REGISTRY_USERNAME",
                    "password": "$CONTAINER_REGISTRY_PASSWORD"
                }
            }
        }
        
        ```
        
        
    1. Replace **`<username>/<image_name>:<tag>`** with the Docker Hub container image name and tag. Note that the **`server`** property in the **`registryCredentials`** object should be set to **`"docker.io"`**.
        
    1. Push the deployment manifest to the Azure IoT Hub:
        
        - In the Azure IoT Hub explorer, right-click on the IoT Hub and select "Create Deployment for Single Device".
        - Select the IoT Edge device and select the deployment manifest file.
        - Click "Create" to build and deploy the deployment manifest to the IoT Edge device.
           
    
    0 comments No comments