Fork me on GitHub
#datalevin
<
2022-01-06
>
mokr21:01:34

Hi, I’m getting liblmdb.so: cannot open shared object file: No such file or directory when I attempt to run my uberjar with embeded Datalevin in Docker. My Dockerfile has a build stage creating the uberjar using clojure:openjdk-11-lein-buster and the final stage utilizes`openjdk:11-slim-buster` to run the jar. I also tried changing both to non-`slim`, but I got the same error. App is based on the Luminus template and works great in dev mode (`lein run`). Are there some libs/packages that needs to be installed or other prerequisites for it to work inside a container? I guess it shouldn’t be an issue as the images supports my architecture, but right now I’m running this is on a MacBook Pro with an M1Pro chip. Prod server will be Ubuntu. PS: Going to bed now, so it will take a while to respond to any follow-ups, but I’ll appreciate any tips here.

Huahai22:01:56

Not sure. LMDBJava extracts the LMDB shared library into Java’s default tmp directory, e.g. it will generate a file /tmp/lmdbdjava-native-library-3975261055459467338.so , load that to use, and finally will delete it on JVM exit. I don’t know how this whole thing plays out in a docker environment.

Huahai23:01:13

The error indicates that the linker tried to load liblmdb.so in its default location but failed. I am not sure why it tried to do that, as the LMDBJava extracted library will have a random name, it’s a temporary file.

Huahai23:01:20

so I think you need to make a /tmp available for your docker container, e.g. bind host /tmp to it, or mount a tmpfs volume, or something else.

Huahai23:01:44

finally, my understanding is that docker images is tied to CPU architecture, so I am not sure that you can run an amd64 docker image on M1 chip?

Huahai23:01:16

the answer is probably no. this also explains why the linker tried to load liblmdb.so instead of a random named one, because it cannot find the right native library with correct architecture, so it failed back to the default name.

Huahai23:01:53

In any case, it is premature for a developer machine to switch to Apple silicon at this point. The ecosystem is just not there yet. Apple doesn’t really care about Java and Linux, so you are on your own if that’s where your deployment will be. It will take a while for the ecosystem to mature, I guess.

Huahai23:01:01

Honestly, I personally SSH into a Linux workstation to write code. A laptop is just for browsing and hosting a terminal. I would recommend any backend engineers to do that same.