DEV Community

Cover image for Spinning up Apache-AGE on Docker
Caleb Mucheru
Caleb Mucheru

Posted on • Edited on

Spinning up Apache-AGE on Docker

This is post recaps on previous posts on using AGE in Docker to entering the psql terminal to using AGE there.
Prerequisites

  1. You need Postgres to be installed. If you do not have it, you can get it from here and build from the source.
  2. Have Docker installed. here

In your PostgreSQL installation's bin folder set up the Postgres server and create you database
initdb postgres
This will give you some command(s) to run.
Create your database:
createdb postgres
Get the apache-age image from the Docker Hub
sudo docker pull apache/age
Run the following command

docker run \
    --name myPostgresDb  \
    -p 5455:5432 \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=your_password \
    -e POSTGRES_DB=postgresDB \
    -d \
    apache/age
Enter fullscreen mode Exit fullscreen mode

Frome the command above:
--name Assign a name to the container
-p Publish a container’s port(s) to the host
-e Set environment variables
-d Run container in background and print container ID

Run the following command to get into psql terminal
psql -h localhost -p 5455 -U postgres


Then do the following to create and load the extension:
postgres=# CREATE EXTENSION age;
CREATE EXTENSION
postgres=# LOAD 'age';
LOAD
postgres=# SET search_path=ag_catalog, "$user", public;
SET
Enter fullscreen mode Exit fullscreen mode

References:

Top comments (0)