# Run on docker / alpine

**URL:** <https://community.konduit.ai/t/run-on-docker-alpine/424>\
**Category:** DL4J\
**Created:** [April 16, 2020, 11:59am UTC](https://community.konduit.ai/t/run-on-docker-alpine/424 "2020-04-16T11:59:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![arnaud22](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/arnaud22/32/1405_2.png) [@arnaud22](https://community.konduit.ai/u/arnaud22)\
**Post date:** [April 16, 2020, 11:59am UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/1 "2020-04-16T11:59:15Z")

</div>

Hi there,

I’m trying to execute maven test into docker container.  
I have this error :

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/konduit/original/1X/52c5302981f59c589a5a02bc95cb074eff538148.png)

ND4J is not supported ?

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/konduit/original/1X/2b6bb008747a4734eb4e1d4f0edf9154f54a2064.png)

what do I have to do ?

thx.

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 16, 2020, 1:13pm UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/2 "2020-04-16T13:13:59Z")

</div>

Can you share your Dockerfile with us? So we know what your Environment inside the container is?

---

<div class="post-metadata">

**Author:** ![arnaud22](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/arnaud22/32/1405_2.png) [@arnaud22](https://community.konduit.ai/u/arnaud22)\
**Post date:** [April 16, 2020, 1:18pm UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/3 "2020-04-16T13:18:57Z")

</div>

Sure :

PATH=/opt/openjdk-13/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tmp/ant/bin  
JAVA\_HOME=/opt/openjdk-13  
JAVA\_VERSION=13-ea+19  
JAVA\_URL=[https://download.java.net/java/early\_access/alpine/19/binaries/openjdk-13-ea+19\_linux-x64-musl\_bin.tar.gz](https://download.java.net/java/early_access/alpine/19/binaries/openjdk-13-ea+19_linux-x64-musl_bin.tar.gz)  
JAVA\_SHA256=010ea985fba7e3d89a9170545c4e697da983cffc442b84e65dba3baa771299a5  
MAVEN\_HOME=/usr/share/maven  
MAVEN\_CONFIG=/root/.m2  
OPENCV\_VERSION=4.1.2  
OPENCV\_SRC\_URL=[https://codeload.github.com/opencv/opencv/tar.gz/4.1.2](https://codeload.github.com/opencv/opencv/tar.gz/4.1.2)  
OPENCV\_INSTALL\_PREFIX=/usr/local/opencv  
OPENCV\_TMP\_DIR=/tmp/opencv  
OPENCV\_BIN=/opt/opencv-java-bin  
ANT\_VERSION=1.10.1  
ANT\_BIN\_URL=[http://archive.apache.org/dist/ant/binaries/apache-ant-1.10.1-bin.tar.gz](http://archive.apache.org/dist/ant/binaries/apache-ant-1.10.1-bin.tar.gz)  
ANT\_TMP\_DIR=/tmp/ant  
ANT\_HOME=/tmp/ant  
LD\_LIBRARY\_PATH=/opt/opencv-java-bin  
TZ=Europe/Paris  
LANG=fr\_FR.UTF-8  
LC\_ALL=C  
HOME=/

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 16, 2020, 1:21pm UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/4 "2020-04-16T13:21:21Z")

</div>

I meant the actual Dockerfile, not the environment variables.

---

<div class="post-metadata">

**Author:** ![arnaud22](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/arnaud22/32/1405_2.png) [@arnaud22](https://community.konduit.ai/u/arnaud22)\
**Post date:** [April 16, 2020, 1:24pm UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/5 "2020-04-16T13:24:53Z")

</div>

I just have the image, i take a look to retrieve the dockerfile.

I go into that image and run “mvn test” into app project folder, so i guess you want the image parent dockerfile, not the dockerfile of my project ?

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 16, 2020, 1:29pm UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/6 "2020-04-16T13:29:38Z")

</div>

I can follow back through the hierarchy of dockerfiles staring from yours, unless you aren’t using public base images.

But I guess the most likely reason you are seeing problems is that you are using a system with musl libc, not glibc.

Take a look at these issues:

> <https://github.com/bytedeco/javacpp/issues/329>
>
> Hi,
> when using nd4j, we're seeing this error with OpenJDK12 on Alpine 3.9:
> 
> \`…app\_1 | Caused by: java.lang.UnsatisfiedLinkError: /usr/local/tomcat/.javacpp/cache/nd4j-native-1.0.0-beta3-linux-x86\_64.jar/org/nd4j/nativeblas/linux-x86\_64/libjnind4jcpu.so: Error loading shared library libmkldnn.so.0: No such file or directory (needed by /usr/local/tomcat/.javacpp/cache/nd4j-native-1.0.0-beta3-linux-x86\_64.jar/org/nd4j/nativeblas/linux-x86\_64//libnd4jcpu.so)
> app\_1 | at java.lang.ClassLoader$NativeLibrary.load0(Native Method) ~\[?:?\]
> app\_1 | at java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2430) ~\[?:?\]
> app\_1 | at java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2487) ~\[?:?\]
> app\_1 | at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684) ~\[?:?\]
> app\_1 | at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2617) ~\[?:?\]
> app\_1 | at java.lang.Runtime.load0(Runtime.java:765) ~\[?:?\]
> app\_1 | at java.lang.System.load(System.java:1866) ~\[?:?\]
> app\_1 | at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1238) ~\[javacpp-1.4.3.jar:1.4.3\]
> app\_1 | at org.bytedeco.javacpp.Loader.load(Loader.java:999) ~\[javacpp-1.4.3.jar:1.4.3\]
> app\_1 | at org.bytedeco.javacpp.Loader.load(Loader.java:891) ~\[javacpp-1.4.3.jar:1.4.3\]
> app\_1 | at org.nd4j.nativeblas.Nd4jCpu.\<clinit\>(Nd4jCpu.java:10) ~\[nd4j-native-1.0.0-beta3.jar:?\]\`
> 
> The seemingly missing library \`libmkldnn.so.0\` exists in \`/usr/local/tomcat/.javacpp/cache/mkl-dnn-0.16-1.4.3-linux-x86\_64.jar/org/bytedeco/javacpp/linux-x86\_64/libmkldnn.so.0\`, but JavaCPP seems to fail telling Alpine where to find it. I don't know how you're doing this, maybe you are setting LD\_LIBRARY\_PATH?

> <https://github.com/docker-library/openjdk/issues/77>
>
> Hello
> 
> When i run my zookeeper some errors 
> 
> \`\`\`
> Error loading shared library li…bjli.so: No such file or directory (needed by /usr/lib/jvm/default-jvm/bin/java)
> Error relocating /usr/lib/jvm/default-jvm/bin/java: JLI\_Launch: symbol not found
> \`\`\`
> 
> \`\`\`
> $ docker run --rm -ti java:8-jre-alpine sh
> / # ldd /usr/lib/jvm/default-jvm/bin/java
> /lib/ld-musl-x86\_64.so.1 (0x7f60e8a6d000)
> Error loading shared library libjli.so: No such file or directory (needed by /usr/lib/jvm/default-jvm/bin/java)
> libc.musl-x86\_64.so.1 =\> /lib/ld-musl-x86\_64.so.1 (0x7f60e8a6d000)
> Error relocating /usr/lib/jvm/default-jvm/bin/java: JLI\_Launch: symbol not found
> \`\`\`
> 
> \`\`\`
> $ docker info
> Containers: 6
> Running: 0
> Paused: 0
> Stopped: 6
> Images: 279
> Server Version: 1.11.1
> Storage Driver: aufs
> Root Dir: /var/lib/docker/aufs
> Backing Filesystem: xfs
> Dirs: 294
> Dirperm1 Supported: true
> Logging Driver: json-file
> Cgroup Driver: cgroupfs
> Plugins: 
> Volume: local
> Network: bridge null host
> Kernel Version: 3.19.0-32-generic
> Operating System: Ubuntu 14.04.4 LTS
> OSType: linux
> Architecture: x86\_64
> CPUs: 4
> Total Memory: 15.62 GiB
> ID: 5I4K:MM6Y:MNCI:R5WU:JQRL:OFHQ:LGJR:EC2A:MYJN:PFRW:GO56:KLAK
> Docker Root Dir: /var/lib/docker
> Debug mode (client): false
> Debug mode (server): false
> Username: cdelgehier
> Registry: https://index.docker.io/v1/
> \`\`\`

---

<div class="post-metadata">

**Author:** ![arnaud22](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/arnaud22/32/1405_2.png) [@arnaud22](https://community.konduit.ai/u/arnaud22)\
**Post date:** [April 16, 2020, 1:48pm UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/7 "2020-04-16T13:48:47Z")

</div>

```auto
ARG MAVEN_VERSION="3"
ARG JDK_VERSION="13"

FROM maven:${MAVEN_VERSION}-jdk-${JDK_VERSION}-alpine

# We must keep this after FROM, otherwise it is removed
ARG JDK_VERSION="13"

ENV ANT_VERSION "1.10.1"
ENV ANT_BIN_URL "http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz"
ENV ANT_TMP_DIR "/tmp/ant"
ENV ANT_HOME "${ANT_TMP_DIR}"
ENV LD_LIBRARY_PATH "${OPENCV_BIN}"
ENV PATH "${PATH}:${ANT_HOME}/bin"
ENV TZ "Europe/Paris"
ENV LANG "fr_FR.UTF-8"
ENV LC_ALL "C"

WORKDIR /app/

COPY settings.xml ${MAVEN_HOME}/ref/
COPY settings.xml ${MAVEN_HOME}/conf/
COPY pom.xml ./
COPY project/pom.xml project/

ARG MVN_OPTS=""
RUN /usr/local/bin/mvn-entrypoint.sh mvn \
      dependency:go-offline \
      -B \
      -Dmaven.artifact.threads=4 \
      ${MVN_OPTS}

RUN rm -rf /app/*
RUN chown -R 1000: ${MAVEN_HOME}

```

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 16, 2020, 1:58pm UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/8 "2020-04-16T13:58:41Z")

</div>

Why is it that you are building opencv manually? Doesn’t the version that you can get via javacpp presets not work for you?

---

<div class="post-metadata">

**Author:** ![arnaud22](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/arnaud22/32/1405_2.png) [@arnaud22](https://community.konduit.ai/u/arnaud22)\
**Post date:** [April 16, 2020, 2:05pm UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/9 "2020-04-16T14:05:08Z")

</div>

Because before we use openCV without DL4J 🙂

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 16, 2020, 2:10pm UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/10 "2020-04-16T14:10:09Z")

</div>

Given all of that, it looks like it is again an incompatibility between musl and glibc.

So either you use a different base image that uses glibc instead of musl or you try using the solutions from the links I’ve posted.

---

<div class="post-metadata">

**Author:** ![saudet](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/saudet/32/69_2.png) [@saudet](https://community.konduit.ai/u/saudet)\
**Post date:** [April 17, 2020, 12:06am UTC](https://community.konduit.ai/t/run-on-docker-alpine/424/11 "2020-04-17T00:06:30Z")

</div>

Yes, ND4J needs glibc. You probably won’t be able to use it with a version of JDK that doesn’t use glibc.
