更新:我通过以下链接完全删除了 Docker: https ://askubuntu.com/a/1021506
然后我像这样重新安装了 Docker: https ://docs.docker.com/engine/install/ubuntu/
重新安装后,mvn jib:dockerBuild
在没有 sudo 的情况下工作。
运行时gcloud auth configure-docker
,它被添加到 .docker/config.json
"credHelpers": {
"asia.gcr.io": "gcloud",
"eu.gcr.io": "gcloud",
"gcr.io": "gcloud",
"marketplace.gcr.io": "gcloud",
"staging-k8s.gcr.io": "gcloud",
"us.gcr.io": "gcloud"
}
并且问题再次出现。在 config.json 中手动删除上述部分可以mvn jib:dockerBuild
再次工作。
运行以下命令
mvn jib:dockerBuild
一个普通的 Micronaut 3.0.2 项目给出了这个输出:
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.7.1:dockerBuild (default-cli) on project barn-validation-step: Build to Docker daemon failed, perhaps you should make sure your credentials for 'registry-1.docker.io/library/openjdk' are set up correctly. See https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#what-should-i-do-when-the-registry-responds-with-unauthorized for help: Unauthorized for registry-1.docker.io/library/openjdk: 401 Unauthorized
[ERROR] GET https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/openjdk:pull
[ERROR] {"details":"incorrect username or password"}
当使用与 sudo 相同的命令时:
sudo env "PATH=$PATH" mvn jib:dockerBuild
构建成功。在 Azure Pipelines 中使用 Maven 步骤时,构建也成功。
我已阅读错误消息中 URL 的内容。我还花了几个小时在其他地方寻找解决方案,到目前为止还没有运气。
我可以使用docker login
, 和
curl https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/openjdk:pull
返回一个令牌