Partially verified
· 5 of 6 code blocks verified
On this page
Run Gitea with Postgres using Docker Compose
Gitea is a lightweight self-hosted Git service. This runs it with a Postgres database on one host.
Prerequisite: Docker Engine with the compose plugin (see Install Docker).
Create the project directory
bash
mkdir -p ~/gitea && cd ~/gitea
Proven
Proof of run
- status
- ✓ Verified
- env
- signal
- exit 0
- checked
- 16 Oct 2026
sha256 693c34b8ec46 · matches the published text
This proof supports the code shown above.
Write the compose file
Open compose.yaml in your editor (nano compose.yaml) and paste:
yamlcompose.yaml
services:
db:
image: postgres:16
restart: unless-stopped
environment:
POSTGRES_USER: gitea
POSTGRES_PASSWORD: gitea
POSTGRES_DB: gitea
volumes:
- ./postgres:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U gitea"]
interval: 5s
retries: 10
gitea:
image: gitea/gitea:1.22
restart: unless-stopped
environment:
GITEA__database__DB_TYPE: postgres
GITEA__database__HOST: db:5432
GITEA__database__NAME: gitea
GITEA__database__USER: gitea
GITEA__database__PASSWD: gitea
volumes:
- ./data:/data
ports:
- "3000:3000"
depends_on:
db:
condition: service_healthy
Proven
Proof of run
- status
- ✓ Verified
- env
- signal
- exit 0
- checked
- 16 Oct 2026
sha256 88b2dd57fea1 · matches the published text
This proof supports the code shown above.
Start it
bash
docker compose up -d
Proven
Proof of run
- status
- ✓ Verified
- env
- signal
- exit 0
- checked
- 16 Oct 2026
sha256 331e4dcccd52 · matches the published text
This proof supports the code shown above.
Check
bash
docker compose ps --format '{{.Service}} {{.State}}'
Proven
Proof of run
- status
- ✓ Verified
- env
- signal
- exit 0
- checked
- 16 Oct 2026
sha256 03889eb056bc · matches the published text
This proof supports the code shown above.
You should see:
output
db running
gitea running
Proven
Proof of run
- status
- ✓ Verified
- env
- signal
- exit 0
- checked
- 16 Oct 2026
sha256 a3db16fa1e79 · matches the published text
This proof supports the code shown above.
Then open http://localhost:3000 — you'll get the Gitea install page.
To follow the logs:
bash
docker compose logs -f gitea