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.22k stars 363 forks source link

Plugin doesn't work when run in WSL Ubuntu 18.04 #704

Closed salunn closed 6 years ago

salunn commented 6 years ago

When running WSL Ubuntu 18.04, I want to be able to build my project's docker images. Because docker daemons cannot be run on WSL, a npiperelay-socat-middleware is built per Microsoft's suggestion. This setup works, I can run any docker command from WSL successfully, e.g. docker run hello-world. However, gradle build with this plugin as dependency fails with "AFUnixSocketException: invalid arguments".

It turns out, cloning this repository and running the functionalTest task results in 140 tests completed, 106 failed, 10 skipped.

Expected Behavior

When equipped with a working docker cli in WSL Ubuntu 18.04, I expect to be able to run the functionalTests and build docker images in general.

Current Behavior

The build fails with AFUnixException: Invalid arguments. The socket tried is now unix://localhost:80

Context

We are currently unable to use WSL as a working building environment, which makes Windows development a lot more difficult.

Steps to Reproduce (for bugs)

  1. Install docker for windows (https://download.docker.com/win/stable/Docker%20for%20Windows%20Installer.exe)
  2. Add WSL to your Windows 10, and install Ubuntu 18.04
  3. Setup npiperelay-socat pipe (https://blogs.technet.microsoft.com/virtualization/2017/12/08/wsl-interoperability-with-docker/)
  4. Clone this repository
  5. Run ./gradlew functionalTest

Your Environment

Windows 10 Pro ver. 1803, build 17134.345 Ubuntu 18.04.1 LTS Docker for Windows: 18.06.1-ce-win73 (19507) Docker on WSL: 18.06.1-ce, build e68fc7a

cdancy commented 6 years ago

When executing on WSL it must be thinking you're really on linux when in fact you're not. You can specify the URL directly instead of having this plugin attempt to guess for you. Give that a go and let me know how things fare.

cdancy commented 6 years ago

There also may be room for a fix here that we can attempt to provide to check if we are running in an "WSL" environment but there really is no docker so maybe fallback to something else.

cdancy commented 6 years ago

@salunn closing this issue. Feel free to re-open if you haven't gotten around your problem.

salunn commented 6 years ago

Sorry, I haven't had the time to look at this. Your suggestion seems intriguing, and would probably work for the problematic computers, but I fear it's not a feasible solution, since our development environment is quite diverse in terms of OSs. I'll get back to the issue when I have the time to test it.

moisei commented 1 year ago

Any update on this issue? I am getting the following exception when I am trying to build an image on WSL2. Env:


Exception in thread "docker-java-stream-1167912859" java.lang.NoClassDefFoundError: Could not initialize class com.bmuschko.gradle.docker.shaded.com.github.dockerjava.transport.DomainSocket
        at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.transport.UnixSocket.get(UnixSocket.java:29)
        at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl$2.createSocket(ApacheDockerHttpClientImpl.java:153)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:125)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:409)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:164)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:174)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:135)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:172)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:93)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:128)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:116)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:178)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:67)
        at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:191)
        at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.httpclient5.ApacheDockerHttpClient.execute(ApacheDockerHttpClient.java:9)
        at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:228)
        at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:269)
        at java.base/java.lang.Thread.run(Thread.java:829)
bmuschko commented 1 year ago

@moisei The issue you are reporting is not related to the original issue. It's this: https://github.com/bmuschko/gradle-docker-plugin/issues/1147