Container Setup
The easiest way to setup a PostgreSQL® server is via a container. This tutorial shows how to setup a postgres Docker container on a Gateway running Kura/ESF.
Warning
This is for demo purposes only; Postgres container has never been fully tested on any Eurotech device since not intended for embedded devices.
Prerequisites:
- Gateway with at least 1,2 GHz processor, 2GB RAM and 512MB free HDD space.
- Docker installed on the system.
- ESF 7.3.0 on the gateway.
Setup the Container Orchestration Provider
Since ESF 7.1.0, it is possible to set up and manage docker containers directly from the framework. This section will recap the main steps detailed in the ESF Documentation to set up a local postgres container on the gateway.
First, set up the Container Orchestration Service by enabling it from the ESF UI and make sure Docker is running on the gateway systemctl status docker
.
In case Docker is not active, issue the following commands (a restart of the gateway is required afterward):
Tip
On some OS, like Raspbian, Docker is not installed by default. Docker can be installed with the following command sequence:
Configure the Container Instance
Next, create a new ContainerInstance
as in the picture below.
The container component configuration does not need many changes. Everything is at default setting except for:
- Enabled:
true
- Image name:
postgres
- Internal Ports:
5432
- External Ports:
5432
- Environment Variables:
POSTGRES_PASSWORD=<password>
The default postgres
user and database are created in the entry point with initdb
. POSTGRES_PASSWORD
is the master superuser password and is required. Other environment variables can be set to configure usernames and other settings. Refer to the Postgres DockerHub for further details.
After hitting Apply
the logs show that the postgres image is pulled and run. The running containers can be verified from the "Device - Containers" section of the ESF UI. The process might take some time, so do not panic if for the first couple of minutes nothing is appearing.
At this point, the container setup on the gateway is completed. The server is reachable at localhost:5432
. Read the PostgreSQL® Client Setup section for the client setup.