JanusGraph is a graph database that stores nodes and relationships instead of tables, or documents. JanusGraph is accessible using the Gremlin query language, which allows retrieving and modifying data in the graph.
This tutorial explains how to install JanusGraph inside a Docker container in the Linux. Commands have been tested on Ubuntu.
Prepare environment
Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.
Install JanusGraph
Before starting, create directory for data:
sudo mkdir -p /opt/janusgraph/data
Set janusgraph
user (ID: 999) as owner for newly created directory:
sudo chown -R 999:999 /opt/janusgraph
Note: it doesn't matter that
user doesn't exist on host system. The janusgraph
user will be created in the container.janusgraph
- Host network
Run the following command to create a container for JanusGraph that uses host network:
docker run -d --name=janusgraph --restart=always --network=host \
-v /opt/janusgraph/data:/var/lib/janusgraph \
janusgraph/janusgraph
- User-defined bridge network
User-defined bridge network can be used for listening on different port. By default, JanusGraph service is listening on port 8182. It can be changed with -p
option.
docker network create app-net
docker run -d --name=janusgraph --restart=always --network=app-net \
-p 8080:8182 \
-v /opt/janusgraph/data:/var/lib/janusgraph \
janusgraph/janusgraph
Testing JanusGraph
Run the following command to start a Gremlin Console:
docker exec -it janusgraph bin/gremlin.sh
The command launches an interactive shell. JanusGraph uses the Gremlin Server for processing client queries. Connect to Gremlin Server using the command:
:remote connect tinkerpop.server conf/remote.yaml
Outputs the following line on successful connection:
==>Configured localhost/127.0.0.1:8182
Exit Gremlin Console:
:exit
Uninstall JanusGraph
To completely remove JanusGraph, remove its container:
docker rm --force janusgraph
Remove JanusGraph image:
docker rmi janusgraph/janusgraph
You can also remove JanusGraph data:
sudo rm -rf /opt/janusgraph
If a user-defined bridge network was created, you can delete it as follows:
docker network rm app-net
Leave a Comment
Cancel reply