spotify/dockerfile-maven 插件:无法构建映像:javax.net.ssl.SSLException:无法识别的 SSL 消息,纯文本连接

Posted

技术标签:

【中文标题】spotify/dockerfile-maven 插件:无法构建映像:javax.net.ssl.SSLException:无法识别的 SSL 消息,纯文本连接【英文标题】:spotify/dockerfile-maven plugin: Could not build image: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection 【发布时间】:2018-03-13 14:44:11 【问题描述】:

maven-plugin 来构建我的 docker 镜像。

每当我运行dockerfile:build

我总是收到这个错误:

"failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.6:build (default-cli) on project XXX: Could not build image"
"Caused by: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?"

我会把错误日志放在最后。

请您看看这里有什么问题吗?

这是我用于此插件的 pom.xml 文件。

<plugin>
        <groupId>com.spotify</groupId>
        <artifactId>dockerfile-maven-plugin</artifactId>
        <version>1.3.6</version>
        <executions>
            <execution>
                <id>default</id>
                <goals>
                    <goal>build</goal>
                    <goal>push</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <repository>company/imagename</repository>
            <tag>$project.version</tag>
        </configuration>
</plugin>

docker版本为:17.06.2-ce

操作系统:Windows 10。

我检查了“general--Expose daemon on tcp://localhost:2375”,还在 docker for windows 中添加了不安全的注册表。

我还在系统变量中添加 DOCKER_HOST="tcp://localhost:2375" 和 DOCKER_CERT_PATH。

dockerfile-build 后的错误日志:

org.apache.maven.plugin.MojoExecutionException: Could not build image
at com.spotify.plugin.dockerfile.BuildMojo.buildImage(BuildMojo.java:185)
at com.spotify.plugin.dockerfile.BuildMojo.execute(BuildMojo.java:105)
at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute(AbstractDockerMojo.java:240)
at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute(AbstractDockerMojo.java:229)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: com.spotify.docker.client.exceptions.DockerException: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at com.spotify.docker.client.DefaultDockerClient.propagate(DefaultDockerClient.java:2512)
at com.spotify.docker.client.DefaultDockerClient.request(DefaultDockerClient.java:2443)
at com.spotify.docker.client.DefaultDockerClient.version(DefaultDockerClient.java:501)
at com.spotify.docker.client.DefaultDockerClient.authRegistryHeader(DefaultDockerClient.java:2555)
at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1396)
at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1365)
at com.spotify.plugin.dockerfile.BuildMojo.buildImage(BuildMojo.java:178)
... 26 more
Caused by: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: **javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?**
at jersey.repackaged.com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:299)
at jersey.repackaged.com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:286)
at jersey.repackaged.com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:116)
at com.spotify.docker.client.DefaultDockerClient.request(DefaultDockerClient.java:2441)
... 31 more
Caused by: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:481)
at org.glassfish.jersey.apache.connector.ApacheConnector$1.run(ApacheConnector.java:491)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
.....

【问题讨论】:

可能您的dockerHost无法访问,您可以将dockerHost设置为unix:///var/run/docker.sock,请提供您的pom.xml的扩展版本 【参考方案1】:

您需要将 pullNewerImage 设置为 false,因为它默认为 true。 更多详情,请参考以下链接。 https://github.com/spotify/dockerfile-maven/issues/3

【讨论】:

以上是关于spotify/dockerfile-maven 插件:无法构建映像:javax.net.ssl.SSLException:无法识别的 SSL 消息,纯文本连接的主要内容,如果未能解决你的问题,请参考以下文章

Jenkins-Pipeline使用示例