Installing Apache AGE with Docker on Windows

markgomer

Marco Aurélio Silva de Souza Júnior

Posted on April 28, 2023

Installing Apache AGE with Docker on Windows

TL;DR:

   docker pull apache/age
   docker run --name age -p 5432:5432 -e POSTGRES_USER=postgresUser -e POSTGRES_PASSWORD=postgresPW -e POSTGRES_DB=postgresDB -d apache/age
   docker exec -it age bash
   psql -U postgresUser -d postgresDB
Enter fullscreen mode Exit fullscreen mode

Done!


In this tutorial, we'll walk through the steps to install Apache AGE on Windows using Docker. Apache AGE is a PostgreSQL extension that allows for graph database functionality. With Docker, we can easily set up a containerized environment for AGE, without having to worry about managing dependencies on our local machine.

Let's get started!

Prerequisites

Before we begin, make sure you have Docker Desktop installed on your Windows machine. You can download it from the official website: https://www.docker.com/products/docker-desktop

Installing Apache AGE on Windows with Docker

  • Open PowerShell or Windows Terminal by right-clicking on the Start menu and selecting "Windows PowerShell" or "Windows Terminal" from the list of options.

  • Type the following command to check if Docker is properly installed and running on your machine:

   docker ps
Enter fullscreen mode Exit fullscreen mode

If everything is set up correctly, you should see output that looks like this:

   CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
Enter fullscreen mode Exit fullscreen mode
  • Next, let's pull the Apache AGE Docker image by running the following command:
   docker pull apache/age
Enter fullscreen mode Exit fullscreen mode

This will download the latest Apache AGE image from Docker Hub. You can verify that the image has been downloaded by running the following command:

   docker images
Enter fullscreen mode Exit fullscreen mode

This should show you a list of all Docker images on your machine, including the Apache AGE image you just downloaded.

REPOSITORY                        TAG        IMAGE ID       CREATED        SIZE
apache/age                        latest     69d1426f38f6   39 hours ago   952MB
Enter fullscreen mode Exit fullscreen mode
  • Now, we need to create a container from the Apache AGE image. Run the following command to create a container:
   docker run --name age -p 5432:5432 -e POSTGRES_USER=postgresUser -e POSTGRES_PASSWORD=postgresPW -e POSTGRES_DB=postgresDB -d apache/age
Enter fullscreen mode Exit fullscreen mode

This command will create a container named "age" from the Apache AGE image, and bind port 5432 (the default PostgreSQL port) on the container to port 5432 on your host machine. It also sets some environment variables for PostgreSQL, including the username, password, and database name.

  • After the container is created, you can verify that it's running by running the following command:
   docker ps
Enter fullscreen mode Exit fullscreen mode

You should see output that looks like this:

   CONTAINER ID   IMAGE        COMMAND                  CREATED          STATUS          PORTS                    NAMES
   1e6298a2a225   apache/age   "docker-entrypoint.s…"   26 minutes ago   Up 26 minutes   0.0.0.0:5432->5432/tcp   age
Enter fullscreen mode Exit fullscreen mode

This indicates that the container is running and has been named "age".

  • Now we need to run some commands inside the container to set up the PostgreSQL database and initialize Apache AGE. To do this, we first need to enter the container's command line interface by running the following command:
   docker exec -it age bash
Enter fullscreen mode Exit fullscreen mode

This will start a bash session inside the "age" container.

  • Once inside the container, we can start the PostgreSQL interactive terminal by running the following command:
   psql -U postgresUser -d postgresDB
Enter fullscreen mode Exit fullscreen mode

This command will start the PostgreSQL interactive terminal with the "postgresUser" username and "postgresDB" database loaded.

  • You should now see a prompt that looks like this:
psql (11.19 (Debian 11.19-1.pgdg100+1), server 11.13 (Debian 11.13-1.pgdg100+1))
Type "help" for help.

postgresDB=#
Enter fullscreen mode Exit fullscreen mode
  • Once you have entered the psql interface, you can start creating and manipulating graphs. AGE follows the PostgreSQL and OpenCypher syntax for creating tables and other database objects, and adds some graph-related keywords and functions.

Some initial commands are found here:
https://age.apache.org/age-manual/master/intro/graphs.html

You can check more information here:

Apache AGE GitHub repository: https://github.com/apache/age
Apache AGE website: https://age.apache.org/

Also check Apache AGE-viewer, its graph visualization tool: https://github.com/apache/age-viewer

💖 💪 🙅 🚩
markgomer
Marco Aurélio Silva de Souza Júnior

Posted on April 28, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related