3

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>
veben
  • 19,637
  • 14
  • 60
  • 80
Paulo Merson
  • 13,270
  • 8
  • 79
  • 72
  • 1
    Are you using Windows 10 Pro? Could you paste your docker-maven-plugin config and %HOME%\.docker\config.json? I had some problems when using it in Windows 10 also. – Eric Hans Feb 13 '17 at 22:44
  • @EricHans: yes, it's Win 10 Pro. I added the plugin config and config.json contents to the question. – Paulo Merson Feb 14 '17 at 10:25
  • What cloud provider do you have? Did you add the server certificate to docker or login ignoring tls? – Eric Hans Feb 14 '17 at 10:53
  • The cloud provider is OpenShift (oc v1.3.0 kubernetes v1.3.0+52492b4). I didn't add a server certificate, but my docker daemon config has my OpenShift private docker registry listed in the "insecure-registries" collection. – Paulo Merson Feb 14 '17 at 12:16

1 Answers1

2

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.

Eric Hans
  • 383
  • 1
  • 5
  • Removing %USER%\.docker solved the problem and I was able to build the image with docker-maven-plugin. When I added `-DpushImageTag`, indeed I saw an error: "Exception caught: unauthorized: authentication required". I removed the "credsStore" element and after the `docker login` command, the "auth" value was automatically filled up, an then `-DpushImageTag` was working. – Paulo Merson Feb 14 '17 at 16:58