Docker
You can run [pgmoneta][pgmoneta] using Docker instead of compiling it manually.
Prerequisites
- [Docker][docker] or [Podman][podman] must be installed on the server where PostgreSQL is running.
- Ensure PostgreSQL is configured to allow external connections.
The image
Enable External PostgreSQL Access
Modify the local PostgreSQL server's postgresql.conf file to allow connections from outside:
listen_addresses = '*'Update pg_hba.conf to allow remote connections:
host all all 0.0.0.0/0 scram-sha-256Then, restart PostgreSQL for the changes to take effect:
sudo systemctl restart postgresqlClone the Repository
git clone https://github.com/pgmoneta/pgmoneta.git
cd pgmonetaBuild the Docker Image
There are two Dockerfiles available:
- Alpine-based image
Using Docker
docker build -t pgmoneta:latest -f ./contrib/docker/Dockerfile.alpine .Using Podman
podman build -t pgmoneta:latest -f ./contrib/docker/Dockerfile.alpine .Rocky Linux 9-based image
Using Docker
docker build -t pgmoneta:latest -f ./contrib/docker/Dockerfile.rocky9 .Using Podman
podman build -t pgmoneta:latest -f ./contrib/docker/Dockerfile.rocky9 .Run pgmoneta as a Docker Container
Once the image is built, run the container using:
Using Docker
docker run -d --name pgmoneta --network host pgmoneta:latestUsing Podman
podman run -d --name pgmoneta --network host pgmoneta:latestVerify the Container
Check if the container is running:
Using Docker
docker ps | grep pgmonetaUsing Podman
podman ps | grep pgmonetaCheck logs for any errors:
Using Docker
docker logs pgmonetaUsing Podman
podman logs pgmonetaYou can also inspect the exposed metrics at:
http://localhost:5001/metricsYou can stop the container using
Using Docker
docker stop pgmonetaUsing Podman
podman stop pgmonetaYou can exec into the container and run the cli commands as
docker exec -it pgmoneta /bin/bash
#or using podman
podman exec -it pgmoneta /bin/bash
cd /etc/pgmoneta
/usr/local/bin/pgmoneta-cli -c pgmoneta.conf shutdownYou can access the three binaries at /usr/local/bin