bmuschko / gradle-docker-plugin

Gradle plugin for managing Docker images and containers.
https://bmuschko.github.io/gradle-docker-plugin/current/user-guide/
Apache License 2.0
1.23k stars 362 forks source link

Not possible to use the plugin on Windows platform #560

Closed Crazyjavahacking closed 6 years ago

Crazyjavahacking commented 6 years ago

Hi,

it looks like the plugin is not working correctly on Windows platform. When we try to use the following task:

task startDockerPostgresContainer(type: DockerStartContainer) { ... }

we got the following stack trace:

java.lang.RuntimeException: Library 'junixsocket-native-2.0.4.dll' not found!
        at org.newsclub.net.unix.NarSystem.getLibPath(NarSystem.java:132)
        at org.newsclub.net.unix.NarSystem.loadLibrary(NarSystem.java:36)
        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.newsclub.net.unix.NativeUnixSocket.<clinit>(NativeUnixSocket.java:35)
        at org.newsclub.net.unix.AFUNIXSocket.<init>(AFUNIXSocket.java:36)
        at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:54)
        at com.github.dockerjava.jaxrs.ApacheUnixSocket.<init>(ApacheUnixSocket.java:51)
        at com.github.dockerjava.jaxrs.UnixConnectionSocketFactory.createSocket(UnixConnectionSocketFactory.java:66)
        at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:118)
        at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
        at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
        at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:435)
        at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:252)
        at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:701)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
        at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:697)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:448)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:349)
        at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
[dockerjava-jaxrs-async-0] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
java.lang.ExceptionInInitializerError
        at org.newsclub.net.unix.AFUNIXSocket.<init>(AFUNIXSocket.java:36)
        at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:54)
        at com.github.dockerjava.jaxrs.ApacheUnixSocket.<init>(ApacheUnixSocket.java:51)
        at com.github.dockerjava.jaxrs.UnixConnectionSocketFactory.createSocket(UnixConnectionSocketFactory.java:66)
        at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:118)
        at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
        at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
        at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:435)
        at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:252)
        at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:701)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
        at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:697)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:448)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:349)
        at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException
        at org.newsclub.net.unix.NativeUnixSocket.<clinit>(NativeUnixSocket.java:42)
        ... 30 more
Caused by: java.lang.reflect.InvocationTargetException
        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.newsclub.net.unix.NativeUnixSocket.<clinit>(NativeUnixSocket.java:35)
        ... 30 more
Caused by: java.lang.RuntimeException: Library 'junixsocket-native-2.0.4.dll' not found!
        at org.newsclub.net.unix.NarSystem.getLibPath(NarSystem.java:132)
        at org.newsclub.net.unix.NarSystem.loadLibrary(NarSystem.java:36)
        ... 35 more

It looks like the plugin is downloading the following Maven artifact: com.kohlschutter.junixsocket:junixsocket-native-common:2.0.4 which in lib directory inside the archive does not contain any Windows specific pre-compiled shared libraries, only Linux and MaxOS ones:

amd64-Linux-gpp
x86_64-MacOSX-gpp

Is Windows supported by this plugin?

cdancy commented 6 years ago

@Crazyjavahacking however unfortunate we have loads of windows users here that use this plugin with no issues to speak of. What version of the plugin are you using? Do you have a reproducible snippet I could try to recreate the issue with?

Crazyjavahacking commented 6 years ago

It turned out that for some reason on Win OS the server URL was still using Unix pipes.

We had to modify each Docker related task to have to following configuration: url = 'tcp://127.0.0.1:2375'. I was expecting that this will happen automatically on Win OS.

Can you verify?

cdancy commented 6 years ago

@Crazyjavahacking the logic we implement can be found HERE but yes, under normal circumstances and assuming you didn't try to override things, we should default to the above URL you noted.

Crazyjavahacking commented 6 years ago

The problem has to be somewhere else. The function is correctly returning the TCP version of the URL, but still failed on the downloading of the artifact.

cdancy commented 6 years ago

@Crazyjavahacking think you may be on to something. As of the release v3.2.5 we started using a shaded version of docker-java (the library we use in the backend to communicate with docker) and I just opened the jar and noticed the jar and noticed the dll you referenced is not there. Poking around for clues now...

cdancy commented 6 years ago

@Crazyjavahacking what version of our plugin are you using?

cdancy commented 6 years ago

Looks like you may be running into THIS ISSUE. Indeed if you're using tcp on windows you shouldn't need to load a dll file.

Crazyjavahacking commented 6 years ago

We are using 3.2.0 version.

cdancy commented 6 years ago

@Crazyjavahacking try using the latest and greatest and see if that helps. Really, if you are in fact pointing at the tcp URL, there should be no reason that the dll is required.

Crazyjavahacking commented 6 years ago

There is no problem with the artifact as it does not exist and newer was published.

My assumption is that some connection factory is only trying to load such native library if the protocol is using Linux pipes, So the problem is more likely to be in not accepting the serverUrl param in version 3.2.0.

cdancy commented 6 years ago

Do you have a reproducible snippet I could try here? We have some developers with windows machines I could ask to give things a go on.

cdancy commented 6 years ago

Closing this issue. Feel free to re-open if you'd like to talk further.

yuluopiaoyang commented 6 years ago

I met the same problem, how should I do?

cdancy commented 6 years ago

@yuluopiaoyang is it reproducible and do you have a snippet we can give a go?

kohlschuetter commented 5 years ago

junixsocket 2.2 now supports Windows 10, please give it a try!