首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >401使用jib创建码头映像时未经授权

401使用jib创建码头映像时未经授权
EN

Stack Overflow用户
提问于 2022-05-17 15:49:14
回答 6查看 2.7K关注 0票数 2

我在windows上,这是插件配置:

代码语言:javascript
复制
<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>jib-maven-plugin</artifactId>
    <version>3.2.1</version>
    <configuration>
        <container>
            <ports>
                <port>8080</port>
            </ports>
            <format>OCI</format>
        </container>
    </configuration>
</plugin>

这是我运行的命令:

代码语言:javascript
复制
.\mvnw clean install jib:dockerBuild -Dimage=fullstack:v1

无论我做什么,这都是我一直犯的错误:

代码语言:javascript
复制
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.2.1:dockerBuild (default-cli) on project SpringBootFullStack: Build
 to Docker daemon failed, perhaps you should make sure your credentials for 'registry-1.docker.io/library/eclipse-temurin' are set up correc
tly. See https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#what-should-i-do-when-the-registry-responds-with-unauthorized f
or help: Unauthorized for registry-1.docker.io/library/eclipse-temurin: 401 Unauthorized
[ERROR] {"details":"incorrect username or password"}
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我该怎么做呢?我读过关于jib github回购的关于身份验证的文档,但我并不真正理解如何进行,并且感到不知所措。

更新

我运行了docker login,我得到:

代码语言:javascript
复制
Authenticating with existing credentials...
Login Succeeded

但是错误仍然存在(我想我没有包括日志记录的某些部分,可能是:

代码语言:javascript
复制
[INFO] Using credentials from Docker config (C:\Users\david\.docker\config.json) for openjdk:17
[INFO] Executing tasks:                               
[INFO] [============                  ] 40.0% complete
[INFO] > building image to Docker daemon              
[INFO]                                                
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.964 s
[INFO] Finished at: 2022-05-17T19:39:12+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.2.1:dockerBuild (default-cli) on project SpringBootFullStack: Build
 to Docker daemon failed, perhaps you should make sure your credentials for 'registry-1.docker.io/library/openjdk' are set up correctly. See
 Unauthorized for registry-1.docker.io/library/openjdk: 401 Unauthorized
[ERROR] {"details":"incorrect username or password"}
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

更新2

这也是为了获取用户名和密码而引用的文件日志的内容:

代码语言:javascript
复制
{
    "auths": {
        "https://index.docker.io/v1/": {}
    },
    "credsStore": "desktop"
}

更新3

经过两天的尝试,我决定寻找其他可以做同样工作的东西:https://spring.io/guides/gs/spring-boot-docker/,用它,工作在10分钟内就完成了。生活真的很疯狂

EN

回答 6

Stack Overflow用户

发布于 2022-08-13 15:02:45

只需从docker文件中删除credsStore属性即可。您将在您的用户主页dir中找到config.json。

路径是:$USER/.docker/config.json,假设文件包含以下内容,

代码语言:javascript
复制
{
  "auths": {
    "https://index.docker.io/v1/": {}
  },
  "credsStore": "desktop"
}

现在删除行:"credsStore":“桌面”

因此,该文件现在将包含以下内容

代码语言:javascript
复制
{
  "auths": {
    "https://index.docker.io/v1/": {}
  }
}
票数 3
EN

Stack Overflow用户

发布于 2022-05-26 15:34:00

代码语言:javascript
复制
{"details":"incorrect username or password"}

服务器的响应是明确的。证书是给服务器的,它说它们是错误的。

事实上,Jib确实从Docker config.json文件中检索了一些凭据(可能不起作用):

代码语言:javascript
复制
[INFO] Using credentials from Docker config (C:\Users\david\.docker\config.json) for openjdk:17

尝试完全清空config.json,或者只删除该文件。特别是,删除"https://index.docker.io/v1/"credsStore的条目。

对于这个堆栈溢出问题来说,可能也是同样的问题。还请看一下这个关于Jib回购的GitHub问题

票数 2
EN

Stack Overflow用户

发布于 2022-05-19 10:46:12

我在Mac上也有过同样的问题。我找到了两种解决问题的方法:

  1. 要做到这一点,您可以使用jib配置:
代码语言:javascript
复制
<configuration>
  ...
  <from>
    <image>aws_account_id.dkr.ecr.region.amazonaws.com/my-base-image</image>
    <auth>
      <username>my_username</username>
      <password>my_password</password>
    </auth>
  </from>
  <to>
    <image>gcr.io/my-gcp-project/my-app</image>
    <auth>
      <username>${env.REGISTRY_USERNAME}</username>
      <password>${env.REGISTRY_PASSWORD}</password>
    </auth>
  </to>
  ...
</configuration>

https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#auth-object

  1. 第二种方法不是关于Windows,我在Mac上解决了这个问题,但是您可以尝试使用我的经验。我觉得这很奇怪,如果我们得到401未经授权,最有可能的Jib试图用一些错误的凭证登录。在我的例子中,我在Keychain中找到了2行:
  • 第一个(错误)与电子邮件的密码(而不是真正的密码)
  • 第二个(正确)和真正的密码Jib试图首先使用。删除第一个值后,问题得到了解决。在windows情况下,您可以尝试使用Credential Manager或查找其他凭据存储。

另外。在我研究的时候,我发现了一些改变的建议:

代码语言:javascript
复制
 "credsStore": "desktop" -> "credStore": "desktop"

但这对我没用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72277087

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档