This guide assumes that you already have Postgres running and helps you set up the pREST using Docker and connect it to your Postgres database.
In case you’d like to run pREST with a fresh Postgres database, follow this guide to deploy the pREST along with a Postgres instance using Docker Compose.
We will use docker to run pREST and connect to an existing database. To simplify the example we leave the authentication module off
docker run -d -p 3000:3000 \ -e PREST_PG_URL=postgres://username:password@hostname:port/dbname \ -e PREST_DEBUG=true \ prest/prest:v1
PREST_PG_URL env var value, so that you can connect to your Postgres instance.
If your password contains special characters (e.g. #, %, $, @, etc.), you need to URL encode them in the
PREST_PG_URLenv var (e.g. %40 for @). You can check the logs to see if the database credentials are proper and if pREST is able to connect to the database. pREST needs access permissions to your Postgres database as described in permissions page.
If your Postgres instance is running on
localhost, the following changes will be needed to the
docker run command to allow the Docker container to access the host’s network.
--net=host flag to access the host’s Postgres service.
This is what your command should look like:
docker run -d --net=host -p 3000:3000 \ -e PREST_PG_URL=...
if you are using another operating system we recommend reading the docker network documentation, on macOS and Windows it is different.
Example using curl:
curl -i -X GET http://127.0.0.1:3000/databases -H "Content-Type: application/json"