Databases & infra

    Deploy PostgreSQL on Oracle Cloud's free tier

    Your own Postgres with real disk, real backups and no row or connection caps.

    At a glance

    Base imagepostgres:16-alpine
    Port5432
    Start commandpostgres
    Infrastructure cost$0 on Oracle Always Free (platform fee for managed DevOps)

    Running PostgreSQL on Ampere ARM

    The official Postgres image is multi-arch, so it runs natively on Ampere. The Always Free block volume allowance (200 GB total) is far more storage than most free managed database tiers offer.

    Steps

    1. Bind to localhost only. Publishing 5432 to 0.0.0.0 exposes your database to the internet. Keep it on 127.0.0.1 and reach it over the Docker network.
    2. Mount a named volume. Without a volume, every redeploy destroys the data directory.
    3. Schedule backups. A nightly pg_dump to Oracle Object Storage keeps a restorable copy off the instance.
      pg_dump -Fc app > /backups/app-$(date +%F).dump

    Dockerfile for PostgreSQL on ARM64

    # Postgres runs from the official image — no custom build needed.
    # docker-compose.yml
    services:
      db:
        image: postgres:16-alpine
        restart: unless-stopped
        environment:
          POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
          POSTGRES_DB: app
        volumes:
          - pgdata:/var/lib/postgresql/data
        ports:
          - "127.0.0.1:5432:5432"
    volumes:
      pgdata:

    Need one tailored to your repository? The free Dockerfile generator writes an ARM-ready multi-stage build for you.

    Common mistakes

    • No backups: Self-hosting means backups are yours to own. Automate them on day one and test a restore.
    • Default shared_buffers: On a 6 GB instance, raising shared_buffers to ~1.5 GB makes a noticeable difference.
    • Exposed port with a weak password: Internet-facing Postgres is scanned within minutes. Keep it private.

    Related reading

    Get the Oracle Always Free deploy checklist

    One email with the exact steps, capacity workarounds and tools we use to ship apps for $0 of cloud spend.

    One email, no spam. Unsubscribe anytime.

    Frequently asked

    Should I use this or Oracle Autonomous Database?+

    Autonomous Database is also Always Free and fully managed, but it is Oracle SQL. Use containerised Postgres when your app expects Postgres.

    How big can the database get?+

    The Always Free tier includes 200 GB of block storage across your boot and block volumes.

    Can my app connect from another VM?+

    Yes, over the private VCN subnet — never over the public internet.

    Deploy your project for $0

    No credit card. No Oracle sales call. Ship to your own cloud in under 10 minutes.

    Start free