Vololodymyr
Vololodymyr

Reputation: 2288

Can't build docker image via gradle on Windows 10

I am new to Docker and i have problems with building image from the gradle script using gradle-docker-plugin :

task dockerBuildImage(type: DockerBuildImage, dependsOn: [dockerCreateDockerfile, assemble]) {
    tag = "my_tag_here"
    dockerFile = dockerCreateDockerfile.destFile
    inputDir = dockerCreateDockerfile.destFile.parentFile
}

And than i am getting such stacktrace:

Building image using context 'D:\Learning\1\myproject\webapp\build'.
Using Dockerfile 'D:\Learning\1\myproject\webapp\build\Dockerfile'
Using tag 'localhost:5000/test/myproject-webapp:1.0.0-20170318135307' for image.
Operating System not officially supported by junixsocket: Windows 10
java.lang.UnsatisfiedLinkError: Could not find library in classpath, tried: [libjunixsocket-windows10-1.8-amd64.so, libjunixsocket-windows10-1.5-amd64.so]
        at org.newsclub.net.unix.NativeUnixSocket.load(NativeUnixSocket.java:81)
        at org.newsclub.net.unix.NativeUnixSocket.<clinit>(NativeUnixSocket.java:112)
        at org.newsclub.net.unix.AFUNIXSocket.<init>(AFUNIXSocket.java:36)
        at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:50)
        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:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
[dockerjava-jaxrs-async-0] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
java.lang.NoClassDefFoundError: Could not initialize class org.newsclub.net.unix.NativeUnixSocket
        at org.newsclub.net.unix.AFUNIXSocketImpl.connect(AFUNIXSocketImpl.java:134)
        at org.newsclub.net.unix.AFUNIXSocket.connect(AFUNIXSocket.java:97)
        at com.github.dockerjava.jaxrs.ApacheUnixSocket.connect(ApacheUnixSocket.java:62)
        at com.github.dockerjava.jaxrs.UnixConnectionSocketFactory.connectSocket(UnixConnectionSocketFactory.java:74)
        at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
        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:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
:webapp:dockerBuildImage FAILED

If i run "docker build" command directly - everything working fine. Can someone point me direction what can be wrong. Any ideas.

Upvotes: 0

Views: 1469

Answers (2)

You're running an old version of junixsocket that does not support Windows. You need to upgrade to a later version.

Try changing your junixsocket dependencies to

<dependency>
  <groupId>com.kohlschutter.junixsocket</groupId>
  <artifactId>junixsocket-core</artifactId>
  <version>2.5.2</version>
  <type>pom</type>
</dependency>

PS: You have another error in the dependency configuration for native-common: <type>pom</type> should only be specified for junixsocket-core, which is a POM-type artifact that includes junixsocket-common and junixsocket-native-common, which are both jar-type artifacts. Therefore just remove that declaration, since junixsocket-core is all you should need.

Upvotes: 0

erickson
erickson

Reputation: 269857

The plugin doesn't support Windows. It assumes you are running on a Linux system, because that's what Docker Engine requires. Docker for Windows uses Hyper-V virtualization (previously it relied on VirtualBox).

You'll need to run this Gradle plugin on a Linux system. That could be a VM on your Windows machine. I prefer to skip Docker for Windows; instead I run VirtualBox with a suitable Linux guest, then follow the installation instructions for Docker Engine inside that guest. Then, alongside docker in that guest, you can install gradle and any other development tools you need.

Upvotes: 5

Related Questions