PostgreSQL

PostgreSQL is a powerful, open-source object-relational database system. It is a great choice for many applications and is easy to use with Spin.

Installation

To install PostgresSQL, you will be prompted to include the PostgresSQL service on install. You simply just need to select it.

Install PostgresSQL

What Spin does for you

When you install PostgreSQL, Spin will set up a dedicated "PostgreSQL" service for you with persistent volumes so you do not lose data when updating your container.

Default Configuration

The database uses the official PostgreSQL image. The default configuration allows us to:

  • ✅ Quickly set up a database service with the exact version of our choice
  • ✅ Automatically create databases, users, and passwords (defined by the environment: variables in the docker-compose.*.yml files)

⚠️ Special Connection Notes

Since the database is running in a container, you will need to connect to the database using the container name. For example, if you have a Laravel application, you would use the following in your .env file:

Example .env File

DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=laravel
DB_USERNAME=laraveluser
DB_PASSWORD=laravelpassword

From your development workstation, we expose the database service on port 5432. This is the default port for PostgreSQL. This means you can use localhost and 5432 to connect to the database.

Usage

When you run spin up, the PostgreSQL container will create our database and start the PostgreSQL service.