2. Graph database/Docker: How to install Neo4j on a docker container? [for Ubuntu 18.04 VM]

Neo4j                                                                                                      Docker-logo

I have shown in this blog/video on the “Installing Neo4j DB on a Docker container using Ubuntu 18.04 VM”.

Through this blog and video, I have demonstrated the below functions:

a) How to install docker on an Ubuntu 18.04 VM?

b) How to create the Neo4j container from the image ?

c) How to use the container for neo4j browser ?

d) How to login and operate the options ?

c) Then how to shutdown the neo4j container ?

On all the above steps, a practiced video is made for your lab practice.

This is attached at the end of this blog.

Step1:
Initially, we need to check whether the prerequisite packages are installed.
To check, perform the following:

sudo apt-get -y install apt-transport-https ca-certificates curl

Step2:
Then, add the docker.com keys to our local keyset:

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –

Step3:
Next, Add the Docker repository to our system (Ubuntu users, I am assuming you have a 64-bit CPU in your VM):

sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

Step4:
Now, we need to work on Preparing the filesystem.
As we planned want need to keep track of the logs and be able to reuse our data, we will need to give the
Docker image some access to our filesystem.
In our home folder [~], let’s create a Neo4j folder and two subfolders named logs and data.
This below script will do it on a Linux platform:
cd ~
mkdir neo4j
cd neo4j
mkdir logs
mkdir data

Enter the above steps in a .sh script.

Step5:
How to Run Neo4j in a Docker container ?:
I need to run the below command;

sudo apt install docker.io

Now, we can run the below long command in a Terminal to run Docker with a Neo4j image.

sudo docker run –rm –publish=7474:7474 –publish=7687:7687 –volume=$HOME/neo4j/data:/data \
–volume=$HOME/neo4j/logs:/logs neo4j:3.1.2

This command triggered some downloading because our local Docker repository does not have the
Neo4j image available in its 3.1.2 version yet.

Ports used by Neo4j are 7474, 7473, and 7687, for the protocols http, https, and bolt, respectively .
In the parameters part, you can see–volume twice.
Its use is to link the folder on the local filesystem to the container filesystem.

Step6:
Providing the port numbers given as parameters were not in use,
the Terminal should display something like this:

Remote interface available at : http://localhost:7474

Now, it denotes our Docker container started for Neo4j.

This informs us that Neo4j is expecting us to connect on port 7474 as usual.
So let us fire our browser and browse to the very same
URL we saw earlier, http://localhost:7474, and go graphing!
(Make sure our data will be persisted on disk.)

Step7:
now, How to stop Docker running your image ?

In order to stop Docker , you need to pass not the name (of the image)
but the identifier of the running container (based on the image).

So, in another Terminal, let us type as follows to know the status of containers:
docker ps

This will list all the containers running, in our case, only one.
So we look at the first column, container_id, and use it as a parameter:
docker stop container_id

You can watch the terminal screen.
Docker container stopped as it should be stopped with this command.

For typical installation procedure of neo4j visit my blog:

https://vskumar.blog/2017/12/08/how-to-install-neo4j-3-2-6-graph-database-on-ubuntu/

 

 

Vcard-Shanthi Kumar V-v3

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s