Setting Up Apache AGE, PostgreSQL, Docker, and pgAdmin on Ubuntu 22.04: A Step-by-Step Guide
If you’re struggling to set up Apache AGE with PostgreSQL, Docker, and pgAdmin on Ubuntu 22.04, trust me — I’ve been there. It can be frustrating, but this guide will walk you through the process step by step.
Before starting, make sure you have installed the following tools:
1. Prerequisites
Before we dive in, make sure you have Docker installed on your Ubuntu system. If not, follow these steps to install it:
Update your package index:
sudo apt update
Install required packages:
sudo apt install ca-certificates curl
Add Docker's official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Add the Docker repository:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Update the package index again:
sudo apt update
Install Docker:
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Add your user to the Docker group (to run Docker without sudo):
sudo usermod -aG docker $USER
Log out and log back in for this to take effect.
2. Verify Docker Installation
Open a terminal and run the following command to check if Docker is working:
docker ps
If Docker is installed correctly, this command will display running containers. Some useful Docker commands:
docker ps -a
# List all containers, running or stoppeddocker stop cont
# Stop the running containerdocker start cont
# Restart a stopped containerdocker rm cont
# Remove a containerdocker logs cont
# View logs of the containerdocker exec -it cont psql -U age -d age
Connect to PostgreSQL inside the container
3. Download the Apache AGE Image from Docker Hub
Run the following command to pull the Apache AGE image:
docker pull apache/age
After downloading, verify the creation of the image with:
docker images
You should see the apache/age image in the list of available images.
4. Create a docker-compose.yml File
To facilitate container management, create a docker-compose.yml file with the following configuration:
version: '3.7'
services:
age:
container_name: cont
image: apache/age
restart: always
environment:
POSTGRES_USER: age
POSTGRES_PASSWORD: age
POSTGRES_DB: age
ports:
- "5432:5432"
networks:
- my_network
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "5050:80"
networks:
- my_network
networks:
my_network:
driver: bridge
(Note: On Ubuntu with newer Docker versions, you can use docker compose
instead of docker-compose
. If you installed via the plugin, use docker compose
for commands.)
5. Start the Containers
In the terminal, navigate to the folder where docker-compose.yml is located and run:
docker compose up -d
This starts PostgreSQL with the Apache AGE extension and also sets up pgAdmin.
6. Access the Apache AGE Container via Terminal
If you want to interact with PostgreSQL and Apache AGE via the terminal, use the following command:
docker exec -it cont bash
Then, access PostgreSQL inside the container:
psql -U age -d age
7. Connecting to Apache AGE via pgAdmin
Open your browser and go to:
http://localhost:5050
Login using:
Email: admin@admin.com
Password: admin
8. Register the PostgreSQL Server in pgAdmin
Inside pgAdmin, go to “Servers” > “Register” > “Server”
In the General tab:
Name: Apache AGE
In the Connection tab:
Host name/address: age (use the service name from docker-compose)
Port: 5432
Maintenance Database: age
Username: age
Password: age
Click Save.
Now, you should be connected to Apache AGE via pgAdmin inside Docker. 🎉
Conclusion
You now have a fully functional environment for working with Apache AGE on PostgreSQL using Docker and pgAdmin on Ubuntu 22.04. You can start executing graph queries and exploring this powerful graph database extension.
If you found this guide helpful, share it with others who might be struggling with the setup! 🚀