Once you realize how addictive and rewarding Open Source Development is, you will end up spending days with it. So here I am working on my WikiToLearn:Ratings project for GSoC-2016.Only few days back it felt that it is good time to choose a proper database application for handling our data , which can be modeled into a graph.We stumbled upon OrientDB a distributed graph database. So here I am sharing my experiences while setting up OrientDB inside Docker.

Just imagine you went to a fine restaurant and you ordered a delicious pizza, as you were busy taming your taste buds you get served with this.

maxresdefault
You are further given some red tomatoes and freshly prepared basil to make sauce and toppings on your own. I know you how do you feel not because I went to such restaurant , but because this is a common scenario that the programmers face.

When we are working in teams it becomes really essential to collaborate seamlessly. That requires that you have a uniform working environment as your fellow team mates. But unfortunately this is not the case. Ever! . There are always some differences in the developing environments that need to be bridged . Now that mostly involves installing dependencies, packages and what not. The situation similar to the pizzeria as we ourselves need to make sauce and toppings for our pizza!

But what if I tell you that there is something that can save you from all this ?

Here comes DOCKER.According to the internet:

“Docker allows you to package an application with all of its dependencies into a standardized unit for software development.”

That means to run an application on any platform you just need to install docker, build the pack with the application and all it’s supporting components and then you are done.
Now anyone using that application only needs docker installed to run that application. No more ugly setup , nothing just run docker and your application is up.

Tasty-Pizza

So recently I got a chance to use docker to fire up my OrientDB database. Therefore in the remaining post I will be explaining what it took to run OrientDB inside Docker!
I am using Ubuntu 14.04(LTS)

  1. Initially we need to download the Docker image of OrientDB .Think of this image as your full application along with all the necessary components to run it.
    So need to a need a set of instructions to download all the dependencies and  install them. This instructions can be run in a batch process with the help of a Dockerfile. Just copy the contents of this file and save it on your disk with your favorite text editor, then run this command on the terminal to build the image from the Dockerfile:docker build -f /path/to/a/Dockerfile .
  2.  

  3. Now once you have the image and the other dependencies you need to run this:docker run -d -p 2424:2424 -p 2480:2480  -v config:/orientdb/config     -v database:/orientdb/databases  -v backup:/orientdb/backup     -e ORIENTDB_ROOT_PASSWORD=mypasswdhere     orientdb:latestSo let’s understand what we just did. We need to run an instance of the image we just built. Docker provides a faculty known as Containers to do it. Containers are like resource friendly virtual machines , a sandbox where you will run your application.
    The -d parameter will detach the container so that it won’t hog the terminal and the container will be up even if your close the terminal.
    -p is used to map the ports.
    As we will be working with the databases we need persistent storage to hold our changes in memory. But the moment we will kill the containers running the application all the data associated with it are destroyed. Therefore we will use Volumes to store the data in main memory.So -v to specify volumes.
  4.  

  5. Your server is up now you can access the web interface by going on this address:http://localhost:2480/
  6.  

  7. If you want to run console you need to additionally issue this command:
    docker run -it --net="host" orientdb:latest /orientdb/bin/console.sh
    The –net=”host” will select the host networking mode in docker. You can read more about networking in docker here.To connect to your database issue:orientdb> connect remote:localhost root <Passwd>
  8.  

  9. Now if you need to kill the container you can issue this command to see the running containers:
    docker ps

    You can see the container name you wish to kill and use:
    docker kill <container name>

 

Congratulations! now you have a fully functional OrientDB server running inside a docker container.

blog local.png

Advertisements