Today I will share about how to create ArangoDB server with Docker and Docker Compose. I found it useful for my development machine.
Here is my scenario. I have Linux Ubuntu 19.10 (eoan) and I want to have ArangoDB server instance. I don't want to install ArangoDB manually but instead just use Docker.
For those who doesn't know about ArangoDB yet, ArangoDB is one of NoSQL database in the market. I already use it on production and so far give me excellent performance and fit with our needs.
According to Wikipedia.
ArangoDB is a free and open-source native multi-model database system developed by ArangoDB GmbH. The database system supports three data models with one database core and a unified query language AQL. The query language is declarative and allows the combination of different data access patterns in a single query.
For more information you can go to https://www.arangodb.com
Preparation
I assume that you already have Docker and Docker Compose installed on your machine. If not, please refer to https://docs.docker.com/install/ for Docker installation and refer to https://docs.docker.com/compose/install/ for Docker Compose installation.
In this case I am on Linux Ubuntu, but the result I think should be similar for other OS.
Compose file
File docker-compose.yml
version: '3.7'
services:
arangodb_db_container:
image: arangodb:latest
environment:
ARANGO_ROOT_PASSWORD: rootpassword
ports:
- 8529:8529
volumes:
- arangodb_data_container:/var/lib/arangodb3
- arangodb_apps_data_container:/var/lib/arangodb3-apps
volumes:
arangodb_data_container:
arangodb_apps_data_container:
What is the Docker Compose file above means?
It will have ArangoDB image and it will take the latest version. As of this writing, the latest version of ArangoDB is 3.6.0. ArangoDB will have user root
and password rootpassword
. It will expose port 8529 to the host machine.
It will also using data container to save the data, called arangodb_data_container
and arangodb_apps_data_container
. It's useful for data persistent, so the data will not be deleted even later you call command docker-compose down
.
Run it
docker-compose up -d
Above command will start the services on detach mode (similar like running in the background).
If everything OK then our ArangoDB server will start.
How to check ArangoDB container is running or not?
Type this command.
docker ps
The result it will look like this.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
88405a9c31e0 arangodb:latest "/entrypoint.sh aran…" 3 seconds ago Up 2 seconds 0.0.0.0:8529->8529/tcp arangodb_arangodb_db_container_1
Looks good and our ArangoDB container is running well.
To check our data container, check with command below.
docker volume ls
It will show like below.
DRIVER VOLUME NAME
local arangodb_arangodb_apps_data_container
local arangodb_arangodb_data_container
That's looks good.
How to connect to ArangoDB server
Via WebUI
Go to http://localhost:8529 or http://127.0.0.1:8529
Via command line (in host machine)
Make sure you have arangosh
client tool command installed on host machine. Refer to https://www.arangodb.com/download-major/ for installing the Client Tools.
arangosh --server.endpoint http+tcp://127.0.0.1:8529 --server.password rootpassword
Via command line (in container)
You can directly run arangosh
client tool command on the container by typing this command.
docker exec -ti CONTAINER_ID arangosh
Replace the CONTAINER_ID
with your container ID.
arangosh screen after successful login
Now we can enjoy our local ArangoDB database server for any purpose we want. For me this setup is fine for testing purpose.
How to stop the ArangoDB server
To shutdown database without delete all containers.
docker-compose stop
To shutdown database and delete all containers.
docker-compose down
That's it and we are done. Relax, if you already create some data it will not gone.
The code above also available on my GitHub repository at https://github.com/sonyarianto/docker-compose-arangodb
Thank you and I hope you enjoy it.
Reference
- https://hub.docker.com/_/arangodb
- https://www.arangodb.com/
- https://en.wikipedia.org/wiki/ArangoDB
- https://docs.docker.com/
- https://docs.docker.com/compose/
Credits
Cover image from photo by Christina Morillo from Pexels at https://www.pexels.com/photo/woman-holding-laptop-beside-glass-wall-1181316/
Top comments (1)
Hey, so I cooked up a simple Express Js server and created a docker compose file with Arango Db & Server as 2 services.
As per the article arango db should be accessible by arango_db_container_name:8529 in express.
But that is not the case. Any idea. what the connection string might be?
on server, all tried urls for connection (as per solutions online)