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
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.
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_apps_data_container. It's useful for data persistent, so the data will not be deleted even later you call command
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.
Type this command.
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.
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
You can directly run
arangosh client tool command on the container by typing this command.
docker exec -ti CONTAINER_ID arangosh
CONTAINER_ID with your container ID.
Now we can enjoy our local ArangoDB database server for any purpose we want. For me this setup is fine for testing purpose.
To shutdown database without delete all containers.
To shutdown database and delete all containers.
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.
Cover image from photo by Christina Morillo from Pexels at https://www.pexels.com/photo/woman-holding-laptop-beside-glass-wall-1181316/