Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build Docker image on Apple Silicon #1779

Closed
saw303 opened this issue Jan 11, 2022 · 6 comments
Closed

Cannot build Docker image on Apple Silicon #1779

saw303 opened this issue Jan 11, 2022 · 6 comments

Comments

@saw303
Copy link

saw303 commented Jan 11, 2022

I'm using a new Apple Silicon Mac and tried to build a Micronaut application. The Micronaut Gradle plugin uses the gradle-docker-plugin under the hood. This issue was initially reported at bmuschko/gradle-docker-plugin#1035.

Is this a known issue?

Dockerfile written to: /tmp/build/Dockerfile
Exception in thread "docker-java-stream--1908892445" java.lang.NoClassDefFoundError: Could not initialize class com.github.dockerjava.httpclient5.UnixDomainSocket
	at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl$2.createSocket(ApacheDockerHttpClientImpl.java:116)
	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:165)
	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.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.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.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.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:149)
	at com.github.dockerjava.httpclient5.ApacheDockerHttpClient.execute(ApacheDockerHttpClient.java:8)
	at com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:228)
	at com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:269)
	at java.base/java.lang.Thread.run(Thread.java:833)
@mareksabo
Copy link

I have the same problem, please have a look at this. 🙏

@KateMost
Copy link

Same in my case, did you find a solution by any chance?

@mareksabo
Copy link

I was implementing support for mac arm_64 architecture, but I found a workaround:

docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:1234:1234 bobrik/socat TCP-LISTEN:1234,fork UNIX-CONNECT:/var/run/docker.sock
export DOCKER_HOST=tcp://localhost:1234
<your-run-command>

Therefore I didn't finish the implementation, this is a WIP patch --
some tests failed on com.github.dockerjava.api.exception.NotFoundException: Status 404: {"message":"network dind-network not found"}, run on java 8.0.322-zulu:

diff --git a/docker-java-transport-netty/pom.xml b/docker-java-transport-netty/pom.xml
index f9bc3bed..e4c26cf6 100644
--- a/docker-java-transport-netty/pom.xml
+++ b/docker-java-transport-netty/pom.xml
@@ -49,6 +49,12 @@
             <version>${netty.version}</version>
             <classifier>osx-x86_64</classifier>
         </dependency>
+	<dependency>
+		<groupId>io.netty</groupId>
+		<artifactId>netty-transport-native-kqueue</artifactId>
+		<version>${netty.version}</version>
+		<classifier>osx-aarch_64</classifier>
+	</dependency>
 	</dependencies>
 
 	<build>
diff --git a/pom.xml b/pom.xml
index 4a036a8e..69f90abd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,12 +68,12 @@
 		<slf4j-api.version>1.7.30</slf4j-api.version>
 
 		<bouncycastle.version>1.64</bouncycastle.version>
-		<junixsocket.version>2.3.2</junixsocket.version>
+		<junixsocket.version>2.4.0</junixsocket.version>
 		<guava.version>19.0</guava.version> <!-- todo remove from project -->
 
 		<!-- test dependencies -->
 		<logback.version>1.2.3</logback.version>
-		<netty.version>4.1.46.Final</netty.version>
+		<netty.version>4.1.73.Final</netty.version>
 		<hamcrest.library.version>2.2</hamcrest.library.version>
 		<hamcrest.jpa-matchers>1.8</hamcrest.jpa-matchers>
 		<lambdaj.version>2.3.3</lambdaj.version>

@hnrkdmsk
Copy link

hnrkdmsk commented Feb 7, 2022

You can try this while waiting for complete implementation:

<!-- Docker client -->
    <dependency>
      <groupId>com.github.docker-java</groupId>
      <artifactId>docker-java</artifactId>
      <version>${docker-java.version}</version>
      <exclusions>
        <exclusion>
          <groupId>com.kohlschutter.junixsocket</groupId>
          <artifactId>junixsocket-common</artifactId> <!-- Apple Silicon not supported -->
        </exclusion>
        <exclusion>
          <groupId>com.kohlschutter.junixsocket</groupId>
          <artifactId>junixsocket-native-common</artifactId> <!-- Apple Silicon not supported -->
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.kohlschutter.junixsocket</groupId>
      <artifactId>junixsocket-common</artifactId>
      <version>2.3.3</version> <!-- Apple Silicon support -->
    </dependency>
    <dependency>
      <groupId>com.kohlschutter.junixsocket</groupId>
      <artifactId>junixsocket-native-common</artifactId>
      <version>2.3.3</version> <!-- Apple Silicon support -->
    </dependency>

In my case, that's how it worked for now.

@stale
Copy link

stale bot commented May 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed Jul 10, 2022
@mpviau
Copy link

mpviau commented Mar 19, 2023

I don't think this is fix, is there a plan for completing the implementation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants