Azure IOT边缘错误提取自定义nodeJS模块的docker映像

时间:2019-05-29 12:02:02

标签: gateway azure-iot-edge

您好,我正在制作一个Azure IOT边缘网关,并尝试在其上安装à自定义模块,但出现此错误:

调用创建模块serverModule时出错:无法创建模块serverModule 造成原因:没有此类图片:MyDockerAzureContainerServer / serverModule:0.0.1-amd64)....

但是如果我跑步

docker pull MyDockerAzureContainerServer / serverModule:0.0.1-amd64

有效!

顺便说一句:我正在使用运行docker Linux容器的winndows10设备

我真的没有得到任何帮助。

deployment.json:

{
    "$schema-template": "2.0.0",
    "modulesContent": {
        "$edgeAgent": {
            "properties.desired": {
                "schemaVersion": "1.0",
                "runtime": {
                    "type": "docker",
                    "settings": {
                        "minDockerVersion": "v1.25",
                        "loggingOptions": "",
                        "registryCredentials": {
                            "Server Name": {
                                "username": "$CONTAINER_REGISTRY_USERNAME_user",
                                "password": "$CONTAINER_REGISTRY_PASSWORD_userPW",
                                "address": "server Name.azurecr.io"
                            }
                        }
                    }
                },
                "systemModules": {
                    "edgeAgent": {
                        "type": "docker",
                        "settings": {
                            "image": "mcr.microsoft.com/azureiotedge-agent:1.0",
                            "createOptions": {}
                        }   
                    },
                    "edgeHub": {
                        "type": "docker",
                        "status": "running",
                        "restartPolicy": "always",
                        "settings": {
                            "image": "mcr.microsoft.com/azureiotedge-hub:1.0",
                            "createOptions": {
                                "HostConfig": {
                                    "PortBindings": {
                                        "5671/tcp": [
                                        {
                                            "HostPort": "5671"
                                        }
                                        ],
                                        "8883/tcp": [
                                        {
                                            "HostPort": "8883"
                                        }
                                        ],
                                        "443/tcp": [
                                        {
                                            "HostPort": "443"
                                        }
                                        ]
                                    }
                                }
                            }
                        }
                    }
                },
                "modules": {
                    "serverModule": {
                        "version": "1.0",
                        "type": "docker",
                        "status": "running",
                        "restartPolicy": "always",
                        "settings": {
                            "image": "${MODULES.serverModule}",
                            "createOptions": {}
                        }
                    }
                }
            }
        },
        "$edgeHub": {
            "properties.desired": {
                "schemaVersion": "1.0",
                "routes": {
                    "serverModuleToIoTHub": "FROM /messages/modules/serverModule/outputs/* INTO $upstream"
                },
                "storeAndForwardConfiguration": {
                    "timeToLiveSecs": 7200
                }
            }
        }
    }
}

(对不起,英语不是我的母语)

1 个答案:

答案 0 :(得分:0)

我终于设法运行它了:

我将docker配置为运行Windows容器并创建了一个dockerfile。 windows-amd64 在执行基本npm安装命令的女巫上 windows

Dockerfile.windows-amd64:

FROM stefanscherer/node-windows:latest
RUN mkdir \app
WORKDIR /app

ONBUILD COPY package.json package.json
ONBUILD RUN npm install
ONBUILD RUN npm install {anny other specific dependencies} --production

ONBUILD COPY . .

CMD [ "node.cmd", "app.js" ]

完成后,需要在已知平台上添加此文件,然后修改projet的module.json文件并添加windows-amd64行:

{
    "$schema-version": "0.0.1",
    "description": "",
    "image": {
        "repository": "{you're Server Name}.azurecr.io/{you're Module}",
        "tag": {
            "version": "0.0.1",
            "platforms": {
                "amd64": "./Dockerfile.amd64",
                "amd64.debug": "./Dockerfile.amd64.debug",
                "arm32v7": "./Dockerfile.arm32v7",
                "arm32v7.debug": "./Dockerfile.arm32v7.debug",
                "Windows-amd64": "./Dockerfile.windows-amd64"
            }
        },
        "buildOptions": []
    },
    "language": "javascript"
}

最后,您需要在deployment.template.json中修改此行:

[...]
 "modules": {
     "{you're Module}": {
         "version": "1.0",
         "type": "docker",
         "status": "running",
         "restartPolicy": "always",
         "settings": {
             "image": "${MODULES.{you're Module}.Windows-amd64}",
             "createOptions": {}
         }
     }
 }
[...]

它应该运行正常。

请注意,我现在在运行docker Windows的Windows计算机上的Windows容器上运行NodeJS应用。

如果有任何问题可以帮助任何人随时与我联系,我会保留此答案。