Skip to content

JanusGraph Container


even though the examples below and in the Docker Compose config files (*.yml) use the latest image, when running a service in production, be sure to specify a specific numeric version to avoid unexpected behavior changes due to latest pointing to a new release version, see our Docker tagging Policy.


Start a JanusGraph Server instance

The default configuration uses the Oracle Berkeley DB Java Edition storage backend and the Apache Lucene indexing backend:

docker run --rm --name janusgraph-default

Connecting with Gremlin Console

Start a JanusGraph container and connect to the janusgraph server remotely using Gremlin Console:

$ docker run --rm --link janusgraph-default:janusgraph -e GREMLIN_REMOTE_HOSTS=janusgraph \
    -it ./bin/

         (o o)
plugin activated: janusgraph.imports
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.spark
plugin activated: tinkerpop.tinkergraph
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured janusgraph/
gremlin> :> g.addV('person').property('name', 'chris')
gremlin> :> g.V().values('name')

Using Docker Compose

Start a JanusGraph Server instance using docker-compose.yml:

docker-compose -f docker-compose.yml up

Start a JanusGraph container running Gremlin Console in the same network using docker-compose.yml:

docker-compose -f docker-compose.yml run --rm \
    -e GREMLIN_REMOTE_HOSTS=janusgraph janusgraph ./bin/


When the container is started it will execute files with the extension .groovy that are found in /docker-entrypoint-initdb.d with the Gremlin Console. These scripts are only executed after the JanusGraph Server instance was started. So, they can connect to it and execute Gremlin traversals.

For example, to add a vertex to the graph, create a file /docker-entrypoint-initdb.d/add-vertex.groovy with the following content:

g = traversal().withRemote('conf/')
g.addV('demigod').property('name', 'hercules').iterate()

Generate Config

JanusGraph-Docker has a single utility method. This method writes the JanusGraph Configuration and show the config afterward.

docker run --rm -it janusgraph show-config

Default config locations are /etc/opt/janusgraph/ and /etc/opt/janusgraph/janusgraph-server.yaml.


The JanusGraph image provides multiple methods for configuration, including using environment variables to set options and using bind-mounted configuration.

Docker environment variables

The environment variables supported by the JanusGraph image are summarized below.

Variable Description Default
JANUS_PROPS_TEMPLATE JanusGraph properties file template (see below). berkeleyje-lucene
janusgraph.* Any JanusGraph configuration option to override in the template properties file, specified with an outer janusgraph namespace (e.g., See JanusGraph Configuration for available options. no default value
gremlinserver.* Any Gremlin Server configuration option to override in the default configuration (YAML) file, specified with an outer gremlinserver namespace (e.g., gremlinserver.threadPoolWorker). You can set or update nested options using additional dots (e.g., gremlinserver.graphs.graph). See Gremlin Server Configuration for available options. See Gremlin Server Environment Variable Syntax section below for help editing gremlin server configuration using environment variables. no default value`
JANUS_SERVER_TIMEOUT Timeout (seconds) used when waiting for Gremlin Server before executing initialization scripts. 30
JANUS_STORAGE_TIMEOUT Timeout (seconds) used when waiting for the storage backend before starting Gremlin Server. 60
GREMLIN_REMOTE_HOSTS Optional hostname for external Gremlin Server instance. Enables a container running Gremlin Console to connect to a remote server using conf/remote.yaml (or remote-objects.yaml). no default value
JANUS_INITDB_DIR Defines the location of the initialization scripts. /docker-entrypoint-initdb.d

Properties template

The JANUS_PROPS_TEMPLATE environment variable is used to define the base JanusGraph properties file. Values in the template properties file are used unless an alternate value for a given property is provided in the environment. The common usage will be to specify a template for the general environment (e.g., cassandra-es) and then provide additional individual configuration to override/extend the template. The available templates depend on the JanusGraph version (see conf/janusgraph*.properties).

berkeleyje all
berkeleyje-es all
berkeleyje-lucene (default) all
cassandra-es <=0.5.3
cql-es >=0.2.1
cql >=0.5.3
inmemory >=0.5.3
Example: Berkeleyje-Lucene

Start a JanusGraph instance using the default berkeleyje-lucene template with custom storage and server settings:

docker run --name janusgraph-default \
    -e \
    -e gremlinserver.threadPoolWorker=2 \

Inspect the configuration:

$ docker exec janusgraph-default sh -c 'cat /etc/opt/janusgraph/ | grep ^[a-z]'

$ docker exec janusgraph-default grep threadPoolWorker /etc/opt/janusgraph/janusgraph-server.yaml
threadPoolWorker: 2
Example: Cassandra-ES with Docker Compose

Start a JanusGraph instance with Cassandra and Elasticsearch using the cql-es template through docker-compose-cql-es.yml:

docker-compose -f docker-compose-cql-es.yml up

Inspect the configuration using docker-compose-cql-es.yml:

$ docker-compose -f docker-compose-cql-es.yml exec \
      janusgraph sh -c 'cat /etc/opt/janusgraph/ | grep ^[a-z]'
cache.db-cache = true
cache.db-cache-clean-wait = 20
cache.db-cache-time = 180000
cache.db-cache-size = 0.25

Gremlin Server Environment Variable Syntax

Environment Variables that start with the prefix gremlinserver. or gremlinserver%d. are used to edit the base janusgraph-server.yaml file. The text after the prefix in the environment variable name should follow a specific syntax. This syntax is implemented using the yq write and delete commands and the yq documentation can be used as a reference for this syntax. Secondly, the value of the environment variable will be used to set the value of the key specified in the environment variable name.

Let's take a look at a few examples:

Nested Properties

For example, say we want to add a configuration property graphs.ConfigurationMangementGraph with the value conf/

$ docker run --rm -it -e gremlinserver.graphs.ConfigurationManagementGraph=\
conf/ janusgraph show-config
  graph: conf/
  ConfigurationManagementGraph: conf/
Delete a component

To delete a component append %d to the 'gremlinserver.' prefix before the closing dot and then select the component following the prefix. Don't forget the trailing '='. For example to delete the graphs.graph configuration property we can do the following:

$ docker run --rm -it -e gremlinserver%d.graphs.graph= janusgraph show-config
graphs: {}
Append item and alternate indexing syntax

This example shows how to append an item to a list. This can be done by adding "[+]" at the end of the environment variable name. This example also shows how to use square bracket syntax as an alternative to the dot syntax. This alternate syntax is useful if one of the keys in the property path contains special characters as we see in the example below.

$ docker run --rm -it -e gremlinserver.scriptEngines.gremlin-groovy\
.files[+]=/scripts/another-script.groovy janusgraph show-config
      org.janusgraph.graphdb.tinkerpop.plugin.JanusGraphGremlinPlugin: {}
      org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}
      org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}
        - java.lang.Math
        - java.lang.Math#*
        - scripts/empty-sample.groovy
        - /scripts/another-script.groovy

Mounted Configuration

By default, the container stores both the and janusgraph-server.yaml files in the JANUS_CONFIG_DIR directory which maps to /etc/opt/janusgraph. When the container starts, it updates those files using the environment variable values. If you have a specific configuration and do not wish to use environment variables to configure JanusGraph, you can mount a directory containing your own version of those configuration files into the container through a bind mount, e.g., -v /local/path/on/host:/etc/opt/janusgraph:ro. You'll need to bind the files as read-only, however, if you do not wish to have the environment variables override the values in that file.

Example with mounted configuration

Start a JanusGraph instance with mounted configuration using docker-compose-mount.yml:

$ docker-compose -f docker-compose-mount.yml up
janusgraph-mount | chown: changing ownership of '/etc/opt/janusgraph/': Read-only file system

Default user JanusGraph

Note: The default user of the image changed for all version beginning with the newest image version of 0.5.3.

The user is created with uid 999 and gid 999 and user's a home dir is /var/lib/janusgraph.

Following folder are created with these user rights: * /var/lib/janusgraph * /etc/opt/janusgraph * /opt/janusgraph * /docker-entrypoint-initdb.d

Image Tagging Policy

Here's the policy we follow for tagging our container images:

Tag Config Support level Docker base image
latest latest JanusGraph release no breaking changes guarantees eclipse-temurin:11-jre
x.x newest patch-level version of JanusGraph expect breaking changes eclipse-temurin:11-jre
x.x.x, x.x.x-revision defined JanusGraph version static tag eclipse-temurin:11-jre
x.x.x-SNAPSHOT latest snapshot build expect breaking changes eclipse-temurin:11-jre
x.x.x-SNAPSHOT-revision latest snapshot build static tag eclipse-temurin:11-jre