首页 > 解决方案 > Faasd - 无法从私有注册表中提取图像

问题描述

我有一个使用 OpenFaaS 的应用程序。

特别是,我使用faasd是因为该功能将在处理能力较差的设备上运行。我有一个私有注册表,其中存在“X”函数的图像。我想从 faasd 中提取此映像以部署和执行它,但我遇到了一个问题:当我尝试执行该操作时,我似乎没有经过身份验证,但我正确传递了 registryAuth 令牌。

这里有一个我正在做的例子(按照这个https://ericstoekl.github.io/faas/operations/managing-images/#deploy-functions-with-private-registries-credentials

邮政

<ip_address>:8080/system/functions

标题:

{
"Authorization": "mytoken"
}

身体:

{
    "service": "functionName",
    "image": "<registry_ip_address>/functions/functionName:<version>",
    "envProcess": "/.../myprocess",
    "registryAuth": <base64 token obtained from 'user:password'>,
    "secrets": [
        "mysecret"
    ]
}

我确认参数都正确,我收到此错误:

“无法提取图像 <registry_ip_address>/functions/functionName:: 无法提取:无法解析引用“<registry_ip_address>/functions/functionName:”:没有为令牌身份验证质询指定范围”

注册表运行良好,因为如果我尝试使用 docker 以经典方式下载图像,我可以提取图像。

先感谢您!

标签: dockerserverlesscontainerdfaasopenfaas

解决方案


对于 faasd,您必须制作一个凭证文件。

您的正常 ~/.docker/config.json 需要复制到/var/lib/faasd/.docker/config.json.

https://github.com/openfaas/faasd#a-note-on-private-repos--registries

关于私人回购/注册的说明

要使用私有镜像仓库,~/.docker/config.json需要复制到/var/lib/faasd/.docker/config.json.

如果您想设置自己的私有注册表,请参阅本教程

请注意,docker login在 MacOS 和 Windows 上运行可能会使用存储在系统帮助程序中的凭据创建一个空文件。

或者,您可以使用registry-loginOpenFaaS 云引导工具 (ofc-bootstrap) 中的命令:

curl -sLSf https://raw.githubusercontent.com/openfaas-incubator/ofc-bootstrap/master/get.sh | sudo sh

ofc-bootstrap registry-login --username <your-registry-username> --password-stdin
# (then enter your password and hit return)

该文件将在./credentials/


推荐阅读