【问题标题】:Azure IOT edge error pulling docker image of custom nodeJS moduleAzure IOT 边缘错误拉取自定义 nodeJS 模块的 docker 映像
【发布时间】:2019-05-29 12:02:01
【问题描述】:

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

调用创建模块 serverModule 时出错:无法创建模块 serverModule 原因:没有这样的图像:MyDockerAzureContainerServer/serverModule:0.0.1-amd64) ....

但是如果我跑了

docker pull MyDockerAzureContainerServer/serverModule:0.0.1-amd64

有效!

顺便说一句:我正在开发一个运行 docker Linux 容器的 winndows10 设备

我真的不明白,谢谢你的帮助。

部署.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
                }
            }
        }
    }
}

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

【问题讨论】:

  • 您是使用私有容器注册表(例如 Azure 容器注册表)还是您的映像驻留在公共 Dockerhub 中?
  • 我确实在使用 Azure 容器注册表
  • 你的deployment.json中有registryCredentials吗? docs.microsoft.com/en-us/azure/iot-edge/…
  • 是的,我知道它们很好,因为在天蓝色中我可以看到图像
  • 你能发布你的整个 deplyomen.json 吗? (删除所有密码等)

标签: gateway azure-iot-edge


【解决方案1】:

我终于设法运行它:

我将 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 应用程序。

如果它可以帮助任何人随时与我联系,如果您有任何问题,我会留下这个答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-02
    • 2018-07-12
    相关资源
    最近更新 更多