Everything needed to run RocksJava Applications (RocksDB w/ Java bindings)
10K+
Dockerfile for RocksJava, the RocksDB Java bindings
The image is available on Docker Hub
The images have been tested on Docker 17.03.1-ce.
If you have your java binaries built by something else, you can run your program in a JVM that contains RocksDB JNI bindings by invoking any java command directly:
docker run \
-v $(pwd)/my-jar.jar:/usr/lib/java/my-jar.jar \
rusnyder/rocksdbjava \
java -cp /usr/lib/java/my-jar.jar com.example.Main
Because construction of java commands (e.g. - classpath, etc.) and arrangement of files can quickly become a little more complex than tenable from the command line, it can make much more sense to use this image as the basis of a Dockerfile of Docker Compose file. To make use in a Dockerfile, you'd likely just copy the classes/jars you needed over, set the classpath, then run java:
Example borrowed from the OpenJDK Docker Hub Repo
FROM rusnyder/rocksdbjava
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
RUN javac Main.java
CMD ["java", "Main"]
An even simpler way, and one that lends itself more to, well, composition, is Docker Compose. There are two "primary" usage modes I see with this Dockerfile, particularly when using Docker Compose:
Mount your entire project
---
version: '3'
services:
myapp:
image: redowl/rocksdbjava
volumes:
- ./:/usr/src/myapp
working_dir: /usr/src/myapp
ports:
- 8080:8080
command: java Main
Mount your lib directory (containining jars) and put them all on the classpath
---
version: '3'
services:
myapp:
image: redowl/rocksdbjava
volumes:
- ./libs/:/usr/lib/java/
environment:
CLASSPATH: /usr/lib/java/*.jar
ports:
- 8080:8080
command: java Main
There is some nuance here when dealing with and specifying the classpath. Here are a few things, in no particular order, to keep in mind:
-cp/-classpath and -jar in the same command, as the
classpath will only be loaded from one or ther other, and whichever is
the last option to occur in the command-line string takes precedence.-cp/-classpath option to your CMD (or command for Docker Compose)CLASSPATH environment variableIf you want to make your RocksDB storage persist from one set of containers to the
next (i.e. - in a dev workflow that involves frequent docker-compose up/down calls),
you may want to consider making sure that the path your application uses for its
RocksDB path is mounted as a volume.
Content type
Image
Digest
Size
280.8 MB
Last updated
over 8 years ago
docker pull rusnyder/rocksdbjava