0

When trying to list all my containers which exist with docker on windows 10 .

I got this error :

Library 'junixsocket-native-2.0.4.dll' not found!

This is my code :

public void listContainer() {
        DefaultDockerClientConfig config
          = DefaultDockerClientConfig.createDefaultConfigBuilder()
            .withDockerHost("unix://172.0.0.2:9200").build();
        DockerClient dockerClient = DockerClientBuilder
                  .getInstance(config)
                  .build();
        List<Container> containers = dockerClient.listContainersCmd().exec() ;      
                for(Container container : containers) {
            System.out.println(container.getId()); 
        
        }

    }

This is my pom.xml

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>3.12.7</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-jwt</artifactId>
            <version>1.0.10.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.github.docker-java</groupId>
            <artifactId>docker-java</artifactId>
            <version>3.0.14</version>
        </dependency>
        <dependency>
  <groupId>com.kohlschutter.junixsocket</groupId>
  <artifactId>junixsocket-server</artifactId>
  <version>2.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.kohlschutter.junixsocket/junixsocket-native -->
<dependency>
    <groupId>com.kohlschutter.junixsocket</groupId>
    <artifactId>junixsocket-native-common</artifactId>
    <version>2.0.4</version>
    <scope>runtime</scope>
    <type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/com.spotify/dockerfile-maven-plugin -->
<dependency>
    <groupId>com.spotify</groupId>
    <artifactId>dockerfile-maven-plugin</artifactId>
    <version>1.4.13</version>
</dependency>
        <dependency>
    <groupId>org.glassfish.jersey.inject</groupId>
    <artifactId>jersey-hk2</artifactId>
    <version>2.26</version>
</dependency>       
    </dependencies>

This is console log :

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.ws.rs.ProcessingException] with root cause

java.lang.RuntimeException: Library 'junixsocket-native-2.0.4.dll' not found! at org.newsclub.net.unix.NarSystem.getLibPath(NarSystem.java:132) ~[junixsocket-native-common-2.0.4.jar:na] at org.newsclub.net.unix.NarSystem.loadLibrary(NarSystem.java:36) ~[junixsocket-native-common-2.0.4.jar:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.newsclub.net.unix.NativeUnixSocket.(NativeUnixSocket.java:35) ~[junixsocket-common-2.0.4.jar:na] at org.newsclub.net.unix.AFUNIXSocket.(AFUNIXSocket.java:36) ~[junixsocket-common-2.0.4.jar:na] at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:54) ~[junixsocket-common-2.0.4.jar:na] at com.github.dockerjava.jaxrs.ApacheUnixSocket.(ApacheUnixSocket.java:51) ~[docker-java-3.0.14.jar:na] at com.github.dockerjava.jaxrs.UnixConnectionSocketFactory.createSocket(UnixConnectionSocketFactory.java:66) ~[docker-java-3.0.14.jar:na] at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:119) ~[httpclient-4.5.13.jar:4.5.13] at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376) ~[httpclient-4.5.13.jar:4.5.13] at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393) ~[httpclient-4.5.13.jar:4.5.13] at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) ~[httpclient-4.5.13.jar:4.5.13] at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) ~[httpclient-4.5.13.jar:4.5.13] at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.13.jar:4.5.13]

1 Answers1

0

junixsocket version 2.0.4 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.