[ Web Proxy ]
URL:
Viewing: https://docs.microsandbox.dev/examples/data/postgresql [Back]  [Original]

PostgreSQL - microsandbox
Skip to main content
Data & Storage

PostgreSQL

Run a persistent PostgreSQL service with a localhost-only forwarded port

Local-only This example runs PostgreSQL 17 in a microVM, stores the database on a sized root disk, and publishes the service only to host loopback.
The current postgres:17-alpine image contains tab characters in DOCKER_PG_LLVM_DEPS. Passing -e DOCKER_PG_LLVM_DEPS= is a temporary compatibility workaround for microsandboxs guest environment validation.

Run PostgreSQL

1

Start PostgreSQL

Set a demo password in the host shell:
Start the database:
With no command after the image, microsandbox runs the images declared docker-entrypoint.sh postgres command in the background.
2

Wait for readiness

3

Run a query

The tested image returned database examples and PostgreSQL 17.10.Applications on the host can connect to 127.0.0.1:55432 with the same database, user, and password.
Environment variables and command arguments are appropriate for this local demo, not for production secrets. Use secret injection, retain the loopback bind, and configure PostgreSQL access controls before allowing remote clients.
4

Clean up

Remove the sandbox and its database:
Clear the password from the host shell:
Previous
Migrations
Next

Web Proxy Viewer  |  New URL  |  Original Page