Prerequisites
Install Docker
Download and install Docker Desktop from docker.com:
- macOS: Download Docker Desktop for Mac
- Windows: Download Docker Desktop for Windows
- Linux: Install Docker Engine using your package manager
Docker Compose is included with Docker Desktop. On Linux, you may need to install it separately.
Install Java 25
You still need Java 25 installed to run the Spring Boot application locally:See the local development guide for detailed Java installation instructions.
Docker Compose configuration
OrgStack includes adocker-compose.yml file that defines the PostgreSQL database service:
This configuration creates a PostgreSQL 16 container with persistent storage using a Docker volume named
orgstack_pg_data.Starting the database
From the root directory of the project, start the PostgreSQL container:- Pull the PostgreSQL 16 image if not already downloaded
- Create a container named
orgstack-postgres - Initialize the database with the specified credentials
- Expose PostgreSQL on port 5432
Verify the database is running
Check that the PostgreSQL container is running:Test the connection
Connect to the database using the PostgreSQL client:You should see the PostgreSQL prompt. Exit with
\q.Running the Spring Boot application
With PostgreSQL running in Docker, you can start the Spring Boot application locally:application.properties:
The Spring Boot application runs on your host machine and connects to the containerized database on
localhost:5432.Managing the Docker containers
Stop the containers
Stop the containers
Start stopped containers
Start stopped containers
Stop and remove containers
Stop and remove containers
Remove everything including data
Remove everything including data
View logs
View logs
Persisting data
The Docker Compose configuration uses a named volumeorgstack_pg_data to persist database data:
- Data survives container restarts
- Data persists when you run
docker compose down - Data is only deleted with
docker compose down -v
Database backup and restore
Containerizing the Spring Boot application
While the current setup runs PostgreSQL in Docker and the application on your host, you can containerize the entire application:Add to docker-compose.yml
Extend the Docker Compose configuration to include the backend:
When services communicate within Docker Compose, use the service name (e.g.,
postgres) as the hostname instead of localhost.Troubleshooting
Port 5432 already in use
Port 5432 already in use
If you have PostgreSQL installed locally and running, it may conflict with the Docker container. Either:
-
Stop the local PostgreSQL service:
-
Or change the port mapping in
docker-compose.yml:Then updateapplication.properties:
Cannot connect to database
Cannot connect to database
Ensure the container is running:Check the logs for errors:Verify the connection parameters match between
docker-compose.yml and application.properties.Database data is lost after restart
Database data is lost after restart
Ensure you’re using
docker compose stop or docker compose down without the -v flag. Using -v removes the data volume:Next steps
Local development
Set up for development without Docker
Production deployment
Deploy OrgStack to production