How to Install PostgresML on Ubuntu 22

The introduction of PostgresML came as good news to Postgres users that look to advance their AI applications by utilizing the Postgres database alongside the machine learning algorithms. If you are new to Postgres or already have it running on your server, you can install PostgresML on Ubuntu 22 with a few steps, provided that you have a guide to follow.

Read on as this post guides you on the steps to follow to install PostgresML on Ubuntu 22. We will see the steps to install PostgreSQL, Docker, and PostgresML. Let’s begin!

Understanding PostgresML

PostgresML is defined as a reliable option to build the interactive AI applications. It works as an open-source AI application database. It utilizes SQL with advanced machine learning algorithms that have pre-trained models to build the interactive and scalable AI-powered solutions.

PostgresML scales the existing Postgres with LLMS, machine learning, vector operations, etc., to allow the users to maximize its potential. Besides, all its integrations occur seamlessly in a shared memory space eliminating cases of data duplication, process boundaries, network calls, and any complexity. That way, the built application becomes scalable, reliable, simple, and fast.

With PostgresML, you only need a few key steps to achieve your goal. First, install it and prepare to get started. Next, train your machine learning model and deploy it to handle your case. Lastly, let the trained model do the prediction to give solutions.

How to Install PostgresML on Ubuntu 22

So far, we understood that PostgresML is an extension of PostgreSQL that brings machine learning to enable the users to train and perform inference on tabular data and other text that utilizes the SQL queries. Therefore, to install PostgresML, you must have Postgres on your system. We will break the installation process into a few steps.

1. Install PostgreSQL

If you have Postgres installed on your system, you can skip this step. However, if you are new to this, you can install PostgreSQL with the following simple commands:

Start by updating your Ubuntu system package.

sudo apt update

Next, install PostgreSQL.

sudo apt install postgresql postgresql-contrib

Once you installed PostgreSQL, start its service as follows:

sudo systemctl start postgresql.service

Now that you have PostgreSQL installed, you can create a user and a database to get started with it. The next step is to install Docker and start its services before we can install the PostgresML.

2. Install Docker

With Docker, you will get a container to comfortably install and build the PostgresML applications. Here, we will install a Docker desktop and we need a 64-bit Ubuntu 22.

To install the Docker desktop, you can source it from the Docker repository or the Ubuntu repositories. The first thing is to remove the previous Docker versions with the following command:

sudo apt-get remove docker docker-engine docker.io containerd runc

Once you removed the previous versions, update your system and run the following command to install any required prerequisite packages:

sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y

Press “y” to confirm the installation of all the packages and wait for the process to complete. If sourcing Docker from its official repository, we must add its GPG key for you to install it on the terminal. So, add the Docker GPG key by executing the following command:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

You should also add the Docker repository that you included with the GPG key to the sources list on your Ubuntu. For that, echo the repository with the following command:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

For the system to notice the added Docker repository, ensure that you update the system repository via the apt command.

sudo apt update

At this point, you can now install Docker using the “docker-ce” package. Run the following command:

sudo apt install docker-ce

Press “y” to start the installation.

You can verify that Docker has been installed by checking its version.

3. Install PostgresML

You are all set and can now install PostgresML. As an open-source project, installing PostgresML requires you to access its GitHub code, clone it, and build the project using the “docker-compose” command.

Let’s start by using git to clone the PostgresML repository with the following command:

sudo git clone https://github.com/postgresml/postgresml.git

The cloning will run up to 100%. Once it completes, you should get an output that is similar to the one in the previous image. You will notice a new directory; “postgresml” has been created.

Navigate into that folder using the “cd” command.

The last step is to use the “docker-compose up” command to build and run the PostgresML database in the containers that are defined in the “compose.yml” file that is stored in the “postgresml” folder. Once you execute the command, it will start building PostgresML.


Ensure that you have a stable internet connection and adequate space. Once the process completes, you will successfully manage to install PostgresML on Ubuntu 22 and can start using it.

Suppose you don’t want this hassle of having to install Docker and go through the cloning and building of PostgresML. You have the option to access the online version of PostgresML where you can sign up and enjoy a working space with 5 GB of data that you can utilize to create your scalable AI-powered solutions. Check out the PostgresML official page and sign up to get started.


This post explained the steps to follow to install PostgresML on Ubuntu 22. We’ve seen the steps to follow, from installing Postgres to installing Docker and PostgresML. Still, we mentioned the simpler option of signing up with PostgresML to utilize it on the browser instead of installing it on the system. That’s it!

About the author

Denis Kariuki

Denis is a Computer Scientist with a passion for Networking and Cyber Security. I love the terminal, and using Linux is a hobby. I am passionate about sharing tips and ideas about Linux and computing.