Marco Aurélio Silva de Souza Júnior
Posted on August 10, 2023
Pre-requisites
For this guide I'll be using Windows 11 with Arch Linux installed on WSL2, and Docker integrated. Docker Desktop needs to be installed on Windows.
This may work on anything that runs Docker, though.
Getting the image
Make sure docker daemon is running by starting Docker Desktop.
If you issue docker ps
and it doesn't throw an error, you may be good to go.
Now go to the official Apache AGE docker hub page and copy the command:
docker pull apache/age
Run it on WSL terminal and it should appear in the list of docker images:
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
apache/age latest dc3b65a4c6fc 44 hours ago 1.34GB
Running the container
Now that you have the image, you need to run a container of it, but it needs very specific variables as per user documentation. From WSL terminal paste:
docker run \
--name age \
-p 5455:5432 \
-e POSTGRES_USER=postgresUser \
-e POSTGRES_PASSWORD=postgresPW \
-e POSTGRES_DB=postgresDB \
-d \
apache/age
Let me break down the command:
docker run
: This is the basic command to start a new Docker container.--name age
: Assigns the nameage
to the container. This name can be used to reference the container in other Docker commands.-p 5455:5432
: Maps port 5432 inside the Docker container to port 5455 on the host machine (WSL). This is useful for connecting to the PostgreSQL service running inside the container from the host system.-e POSTGRES_USER=postgresUser
: Sets an environment variablePOSTGRES_USER
inside the container, assigning it the valuepostgresUser
. This is the username used to connect to the PostgreSQL database.-e POSTGRES_PASSWORD=postgresPW
: Sets an environment variablePOSTGRES_PASSWORD
inside the container, assigning it the valuepostgresPW
. This is the password used to connect to the PostgreSQL database.-e POSTGRES_DB=postgresDB
: Sets an environment variablePOSTGRES_DB
inside the container, assigning it the valuepostgresDB
. This is the name of the database to which connections will be made by default.-d
: Runs the container in detached mode. This means that the container will run in the background, and you won't see its output in the terminal.apache/age
: This is the name of the Docker image to be used for the container. It refers to a specific image that has Apache AGE installed and configured.
With that there will be a running container on background:
Using Apache AGE from container
Now on Docker Desktop, click on age, the recently created container.
Now click "Terminal" and "Open in external terminal"
It will open your default terminal logged in to root.
Now run the command:
psql -h 0.0.0.0 -p 5432 -d postgresDB -U postgresUser
Immediately you will be inside psql, logged in to "postgresUser" in the "postgresDB" database, which were created upon the prior docker run command.
# psql -h 0.0.0.0 -p 5432 -d postgresDB -U postgresUser
psql (14.8 (Debian 14.8-1.pgdg120+1))
Type "help" for help.
postgresDB=#
Apache AGE comes already loaded, so you can start using it right away:
postgresDB=# SET search_path TO ag_catalog;
SET
postgresDB=# SELECT * FROM ag_graph;
graphid | name | namespace
---------+------+-----------
16950 | test | test
(1 row)
postgresDB=# SELECT * FROM ag_label;
name | graph | id | kind | relation | seq_name
------------------+-------+----+------+-----------------------+-------------------------
_ag_label_vertex | 16950 | 1 | v | test._ag_label_vertex | _ag_label_vertex_id_seq
_ag_label_edge | 16950 | 2 | e | test._ag_label_edge | _ag_label_edge_id_seq
(2 rows)
postgresDB=#
And that's a wrap! Have fun!
I make these posts in order to guide people into the development of a new technology. If you find anything incorrect, I urge you to comment below so I can fix it. Thanks!
Check Apache AGE: https://age.apache.org/.
Overview — Apache AGE master documentation: https://age.apache.org/age-manual/master/intro/overview.html.
GitHub - apache/age: https://github.com/apache/age
Posted on August 10, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.