Reputation: 47
I am working with janusgraph. I have built a janusgraph image. What I want is to run this janusgraph container, at the same time, connect to cassandra container and elasticsearch container, and finally expose 8182 port to host machine.
My problem is: how to let janusgraph connect to cassandra by ip and 9042 port and elasticsearch by ip and 9200/9300 port?
Upvotes: 1
Views: 383
Reputation: 57798
First, you'll want to EXPOSE
those ports in your Dockerfile. Your Dockerfile is where you'll also want to define an ARG
for the Cassandra cluster endpoints.
Dockerfile:
# argument for the Cassandra endpoints, with a default value of 127.0.0.1
ARG CASSANDRA_ENDPOINT_LIST=127.0.0.1
# Exposing required ports 8182(gremlin) 9042(Cassandra) 9200(ElasticSearch)
EXPOSE 8182 9042 9200
Then do a regex/replace with sed
in your entrypoint file:
sed -i "s/hostname=127\.0\.0\.1/hostname=${CASSANDRA_ENDPOINT_LIST}/g" ${JANUSGRAPH_CONF}/gremlin-server/janusgraph-cql-es-server.properties
When building the Docker container, pass CASSANDRA_ENDPOINT_LIST
as a build argument:
--build-arg CASSANDRA_ENDPOINT_LIST=1.2.3.4,1.2.3.5
This example is geared toward Cassandra, but something similar will work for ElasticSearch, too.
Note: You could also build all 3 inside the same container, and then you wouldn't need to pass the endpoints via --build-arg
. Although, you'd need enough RAM to support JVMs for Janus, Elastic, and Cassandra.
Upvotes: 1