Docker for Windows和docker-maven-plugin - “SSLException:无法识别的SSL消息,明文连接”错误

问题描述 投票:3回答:1

我在我的本地Windows 10 Pro计算机上使用Docker Desktop for Windows v1.13.0和docker-maven-plugin v0.4.13。我正在使用mvn clean package docker:build来构建我的项目并生成docker镜像。构建失败:

[INFO] ----------------------------------------------- ------------------------- [INFO] BUILD FAILURE [INFO] ----------------- -------------------------------------------------- ----- [INFO]总时间:25.006秒[INFO]完成时间:2017-01-19T14:48:45-02:00 [INFO]最终记忆:68M / 619M [INFO] ------ -------------------------------------------------- ---------------- [错误]无法执行目标com.spotify:docker-maven-plugin:0.4.13:build(default-cli)on project monitoramentoRS:异常捕获: java.util.concurrent.ExecutionException:com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException:javax.net.ssl.SSLException:无法识别的SSL消息,明文连接? - > [帮助1]

直接在命令行上创建docker镜像(docker build -t ...)工作正常。 maven插件在Windows 7上与Docker工具箱和Oracle Virtual Box一起正常运行。

因此,我相信docker-maven-plugin和Docker for Windows守护进程之间存在TLS相关的配置问题。我尝试使用DOCKER_HOST(无端口指示,2375,2376),DOCKER_TLS_VERIFYDOCKER_TLS的不同配置组合无济于事。还尝试了用于Windows守护程序配置的“高级”Docker的"tls""tlsverify"属性。

有没有人能够使docker-maven-plugin在Docker for Windows上创建一个docker镜像?

我的%HOME%\.docker\config.json文件只包含一个auths集合:

{
    "auths": {
        "our-corporate-private-docker-registry-address": {
            "auth": "an-authorization-token"
        },
        "https://index.docker.io/v1/": {
            "auth": "an-authorization-token"
        }
    }
}

下面是docker-maven-plugin配置。

<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.4.13</version>
    <configuration>
        <useConfigFile>false</useConfigFile> <!-- true yields the same error -->
        <registryUrl>${docker.private.registry}</registryUrl>
        <imageName>${docker.private.registry}/myrepo/myimage</imageName>
        <imageTags>
            <imageTag>latest</imageTag>
        </imageTags>
        <dockerDirectory>${basedir}/docker</dockerDirectory>  <!-- Dockerfile location -->
        <resources>
            <resource>
                <targetPath>/</targetPath>
                <directory>${project.build.directory}</directory>                                           <include>${project.build.finalName}.${project.packaging}</include>
            </resource>
        </resources>
    </configuration>
</plugin>
docker docker-for-windows docker-desktop docker-maven-plugin
1个回答
2
投票

%HOME%.docker下可能有一些配置元素影响与docker-maven-plugin的通信。尝试删除%HOME%.docker文件夹并重新启动docker。之后,运行

oc login -u user https://url-to-openshift:port --insecure-skip-tls-verify

docker login -u user -p token url-to-private-registry

然后打开%HOME%.docker,如果你的文件是这样的:

{
   "auths": {
      "url-to-private-registry": {}
   },

   "credsStore": "wincred"    
}

然后删除credsStore部分因为spotify docker-maven-plugin不支持它。

例:

{
   "auths": {
      "url-to-private-registry": {}
   }
}

当您再次运行docker登录时,它将再次生成令牌,您不应该有任何身份验证问题。

登录后,您的%HOME%.docker \ config.json将如下所示:

{
   "auths": {
      "url-to-private-registry": {
          "auth:" "token-that-docker-maven-plugin-needs-when-property-useConfigFile-is-true"
      }
   }
}

至少,它对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.