Search code examples
dockerdocker-for-windowsdocker-desktopdocker-maven-plugin

Docker for Windows and docker-maven-plugin - "SSLException: Unrecognized SSL message, plaintext connection" error


I'm using Docker Desktop for Windows v1.13.0 and docker-maven-plugin v0.4.13 on my local Windows 10 Pro machine. I'm using mvn clean package docker:build to build my project and generate the docker image. The build fails:

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 25.006 s [INFO] Finished at: 2017-01-19T14:48:45-02:00 [INFO] Final Memory: 68M/619M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (default-cli) on project monitoramentoRS: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? -> [Help 1]

Creating the docker image on the command line directly (docker build -t ...) works fine. The maven plugin was working fine with Docker toolbox and Oracle Virtual Box on Windows 7.

Therefore, I believe there's a TLS-related configuration issue between docker-maven-plugin and the Docker for Windows daemon. I've tried different configuration combinations using DOCKER_HOST (no port indication, 2375, 2376), DOCKER_TLS_VERIFY, and DOCKER_TLS to no avail. Also tried the "tls" and "tlsverify" attributes of the "advanced" Docker for Windows daemon configuration.

Has anyone been able to make docker-maven-plugin create a docker image on Docker for Windows?

My %HOME%\.docker\config.json file only contains an auths collection:

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

Below is the docker-maven-plugin config.

<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>

Solution

  • There might be some configuration element under %HOME%.docker affecting the communication with docker-maven-plugin. Try to remove your %HOME%.docker folder and restart docker. After that, run the

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

    and

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

    and then open the %HOME%.docker and if your file is like this:

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

    then remove the credsStore part because the spotify docker-maven-plugin doesn't support it.

    Example:

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

    When you run the docker login again, it will generate the token again and you shouldn't have any authentication problem.

    After the login, your %HOME%.docker\config.json will look like this:

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

    At least, it worked for me.