摆正姿势:无法检索.docker / config.json

时间:2019-09-24 02:49:25

标签: docker-compose minikube kompose

我正在使用kompose在Mac上转换一个简单的docker-compose文件。但是每次我跑步时我都会得到:

WARN Unable to retrieve .docker/config.json authentication details. Check that 'docker login' works successfully on the command line.: Failed to read authentication from dockercfg 
INFO Authentication credentials are not detected. Will try push without authentication. 
INFO Attempting authentication credentials 'docker.io 
ERRO Unable to push image 'bolbeck/simplepythonimage:latest' to registry 'docker.io'. Error: denied: requested access to the resource is denied 
FATA Error while deploying application: k.Transform failed: Unable to push Docker image for service firstpythonhw: unable to push docker image(s). Check that `docker login` works successfully on the command line 

kompose convert可以正常工作,因为它不会尝试提取图像。此外,docker login在终端上也可以正常工作,我可以手动推送图像。

这是docker-compose文件:

version: "3"

services:
  firstpythonhw:
    build: .
    image: MyAccount/pythonimage
    container_name: pythonhw
    ports:
      - "5000:5000"

我正在使用Kompose版本1.18.0和Minikube版本1.4.0

2 个答案:

答案 0 :(得分:0)

根据Kompose文档,在Push图片操作期间,实际上按照以下文件夹检查顺序从docker配置文件中检索了Docker身份验证数据:

$DOCKER_CONFIG/config.json, $HOME/.docker/config.json , $HOME/.dockercfg

实际上,当您通过docker login登录到注册表时,该命令会将凭据保存在config.json文件中。但是,Docker还提供了一种方法,该方法如何通过 Credential stores 在外部存储用户身份验证数据,甚至是整个OS范围的钥匙链的主要存储。但是这次Kompose将无法识别Docker配置文件和整个内容结构。

在Mac中,您可以找到macOS keychain,因为您已经检查了docker login,我想base64编码的凭据没有存储在config.json文件中,它们只是导出到” osxkeychain”

更新

典型的config.json文件结构:

{
        "auths": {
                "https://index.docker.io/v1/": {
                        "auth": "base64 encoded username:password"
                }
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/18.09.7 (linux)"
        }
}

答案 1 :(得分:0)

尝试以下命令在您的计算机上生成base64字符串

echo -n 'username:password'  | base64

获取此输出

并添加到docker compose文件

{
        "auths": {
                "https://index.docker.io/v1/": {
                        "auth": "your base 64 string"
                }
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/18.09.7 (linux)"
        }
}