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.
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
Then, add the docker.com keys to our local keyset:
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
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”
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:
Enter the above steps in a .sh script.
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 \
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.
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.)
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:
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: