Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从kubernetes的私人回购中退出失败;“秘密”;“码头工人证书”;无效:数据[.dockerconfigjson]:必需值;_Docker_Kubernetes_Private Repository - Fatal编程技术网

从kubernetes的私人回购中退出失败;“秘密”;“码头工人证书”;无效:数据[.dockerconfigjson]:必需值;

从kubernetes的私人回购中退出失败;“秘密”;“码头工人证书”;无效:数据[.dockerconfigjson]:必需值;,docker,kubernetes,private-repository,Docker,Kubernetes,Private Repository,我试图从我的docker hub repo中提取图像。我遵循了这里的文档: 但是,在键入命令后: kubectl创建机密的通用docker凭据--从文件=/my/local/path/到/.docker/config.json--type=kubernetes.io/dockerconfigjson 我得到以下错误: 机密“docker凭据”无效:数据[.dockerconfigjson]: 要求值 我尝试删除config.json并重新登录,但行为没有改变 docker版本打印: Client

我试图从我的docker hub repo中提取图像。我遵循了这里的文档:

但是,在键入命令后:

kubectl创建机密的通用docker凭据--从文件=/my/local/path/到/.docker/config.json--type=kubernetes.io/dockerconfigjson

我得到以下错误:

机密“docker凭据”无效:数据[.dockerconfigjson]: 要求值

我尝试删除config.json并重新登录,但行为没有改变

docker版本打印:

Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea838
 Built:             Wed Nov 13 07:29:52 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea838
  Built:            Wed Nov 13 07:28:22 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
kubectl版印刷品:

Client Version: version.Info{
  Major:"1",
  Minor:"17",
  GitVersion:"v1.17.2",
  GitCommit:"59603c6e503c87169aea6106f57b9f242f64df89",
  GitTreeState:"clean",
  BuildDate:"2020-01-18T23:30:10Z",
  GoVersion:"go1.13.5",
  Compiler:"gc",
  Platform:"linux/amd64"
}
Server Version: version.Info{
  Major:"1",
  Minor:"15",
  GitVersion:"v1.15.2",
  GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568",
  GitTreeState:"clean",
  BuildDate:"2019-08-05T09:15:22Z",
  GoVersion:"go1.12.5",
  Compiler:"gc",
  Platform:"linux/amd64"
}
config.json如下所示:

{
    "auths": {
        "https://index.docker.io/v1/": {
            "auth": "secret-stuff"
        }
    },
    "HttpHeaders": {
        "User-Agent": "Docker-Client/19.03.5 (linux)"
    }
}

目前,我可以手动输入凭据,但我想了解出了什么问题。任何帮助都将不胜感激

您没有使用docker private repository运行docker login命令,因此config.json文件没有身份验证信息。您可以参考下面的示例文件

例如:

  {
    "auths": {

     "https://dockerhub.xxxxx.com": {
        "auth": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
        "email": "xxxxx@xxxxx.com"
     }
   },
   "HttpHeaders": {
      "User-Agent": "Docker-Client/18.06.1-ce (linux)"
   }
 }

创建
secret
时,您没有指定要从中读取的文件的
类型,因此
kubectl
没有正确读取该文件

类型列表如下:

SecretTypeOpaque SecretType = "Opaque"
[...]
SecretTypeServiceAccountToken SecretType = "kubernetes.io/service-account-token"
[...]
SecretTypeDockercfg SecretType = "kubernetes.io/dockercfg"
[...]
SecretTypeDockerConfigJSON SecretType = "kubernetes.io/dockerconfigjson"
[...]
SecretTypeBasicAuth SecretType = "kubernetes.io/basic-auth"
[...]
SecretTypeSSHAuth SecretType = "kubernetes.io/ssh-auth"
[...]
SecretTypeTLS SecretType = "kubernetes.io/tls"
[...]
SecretTypeBootstrapToken SecretType = "bootstrap.kubernetes.io/token"

你可以在Kubernetes GitHub找到

在您的情况下,正确的命令是
kubectl创建机密的通用docker凭据--从文件=.dockerconfigjson=path/to/.docker/config.json--type=kubernetes.io/dockerconfigjson


请注意
--from file=.dockerconfigjson=path/to/.docker/config.json
,您应该只编辑
path/to/.docker/config.json
我遇到了与
kubectl create secret generic--type=kubernetes.io/dockerconfigjson
相同的问题(“秘密“xxx”无效:数据[.dockerconfigjson]:Required value”),这是因为命令行中的错误,我认为Marcus的命令也有错误

我有:

--from file=/run/user/xxxx/containers/auth.json

它应该是:

--from file=.dockerconfigjson=/run/user/xxxx/containers/auth.json

我错误地将--from file选项解释为采用了文件路径,但它采用了key=value,我猜在本例中应该是key“.dockerconfigjson”

克劳的回答暗示——从文件中可以看出,他是罪魁祸首,但我想我会添加一个答案来说明遗漏了什么。(我认为关于文件
type
丢失的观点是误导性的,因为命令中有--type选项,这就是我在查看此问题寻求帮助时跳过该答案的原因。)

请注意,我通过在详细模式下运行kubectl(--v=N,请参阅)得到了错误的提示,这表明kubectl告诉API服务器秘密资源的结构,而结构没有像我从Kubernetes文档中的秘密YAML示例中预期的那样显示“.dockerconfigjson”