Deploy Gogs with Dokploy: Docker Compose Setup Guide
Step-by-step guide to deploying Gogs Git hosting on your VPS using Dokploy and Docker Compose. Includes PostgreSQL database, SSH access, and SSL configuration.
Deploy Gogs with Dokploy
Dokploy is an open-source server management platform that simplifies deploying Docker Compose applications on your VPS. It handles reverse proxy configuration, SSL certificates, and deployment management — making it ideal for running Gogs as an extremely lightweight, self-hosted Git service.
This guide walks you through deploying Gogs with a PostgreSQL database backend, persistent repository storage, SSH access, and automatic HTTPS. Gogs is designed to be the simplest and fastest way to set up a self-hosted Git service.
Prerequisites
- A VPS with at least 1 vCPU, 1 GB RAM, and 10 GB storage
- Dokploy installed and running on your server (installation docs)
- A domain name (e.g.,
git.yourdomain.com) with DNS A record pointing to your server's IP
Docker Compose Configuration
Create a new Compose project in Dokploy and paste the following configuration:
version: "3.8"
services:
gogs:
image: gogs/gogs:latest
restart: unless-stopped
ports:
- "3000:3000"
- "2222:22"
volumes:
- ../files/gogs-data:/data
depends_on:
gogs-db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:3000/healthcheck || exit 1"]
interval: 30s
timeout: 10s
retries: 3
gogs-db:
image: postgres:16-alpine
restart: unless-stopped
environment:
- POSTGRES_DB=gogs
- POSTGRES_USER=gogs
- POSTGRES_PASSWORD=${GOGS_DB_PASSWORD}
volumes:
- ../files/gogs-db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U gogs"]
interval: 10s
timeout: 5s
retries: 5
Note: Port 2222 is mapped for SSH Git operations. Gogs is configured through the web-based installer on first run, where you set the database connection, domain, and admin account. The database settings entered during installation must match the PostgreSQL service above.
Environment Variables
Set these in Dokploy's Environment tab for your compose project:
| Variable | Purpose | Example |
|---|---|---|
GOGS_DB_PASSWORD |
PostgreSQL database password | a-strong-random-password |
In Dokploy, environment variables are set via the Environment editor in the project settings. Do not create a .env file manually — Dokploy manages this for you. Gogs configuration is primarily done through the web installer on first run, which writes to /data/gogs/conf/app.ini inside the container.
Volumes & Data Persistence
This setup uses Dokploy's ../files convention for bind-mounted volumes:
../files/gogs-data— Git repositories, Gogs configuration (app.ini), SSH keys, avatars, and attachments../files/gogs-db-data— PostgreSQL database files
The ../files path is relative to the compose file inside Dokploy's project directory. This ensures your data persists across redeployments. Avoid using absolute paths (e.g., /opt/gogs) because Dokploy may clean them during redeployment.
If you need S3 backup support, consider using named Docker volumes instead. Named volumes can be backed up with Dokploy's built-in backup features.
Domain & SSL Setup
- In your Dokploy project, navigate to the Domains tab
- Click Add Domain and enter your domain (e.g.,
git.yourdomain.com) - Set the container port to
3000 - Enable HTTPS — Dokploy automatically provisions a Let's Encrypt SSL certificate
- Save and wait for the certificate to be issued (usually under a minute)
Dokploy's built-in Traefik reverse proxy handles TLS termination and routes traffic to the Gogs container. SSH Git access uses port 2222 directly, bypassing the reverse proxy.
Verifying the Deployment
- In Dokploy, go to your project's Deployments tab and click Deploy
- Watch the build logs — you should see both
gogsandgogs-dbcontainers start - Check the Logs tab for the
gogsservice. Look for:Listen on 0.0.0.0:3000 - Open
https://git.yourdomain.comin your browser — you should see the Gogs installation page on first run - During installation, set Database Type to
PostgreSQL, Host togogs-db:5432, User togogs, Password to yourGOGS_DB_PASSWORD, and Database Name togogs - Set the Domain to
git.yourdomain.com, SSH Port to2222, and Application URL tohttps://git.yourdomain.com/ - Create the admin account and finish installation
Troubleshooting
Gogs installation page shows "Database connection failed"
Ensure the PostgreSQL container is healthy. During installation, use gogs-db as the database host (the Docker service name), port 5432, and the credentials matching the environment variables. The database gogs must already exist (the PostgreSQL container creates it automatically).
SSH clone fails with "Connection refused"
Verify port 2222 is open on your VPS firewall. Use the correct SSH URL format: ssh://git@git.yourdomain.com:2222/user/repo.git. Ensure SSH is enabled in Gogs' app.ini configuration.
Repositories lost after container restart
Ensure the ../files/gogs-data volume is correctly mapped to /data. All Gogs data including repositories, configuration, and uploaded content lives under this directory.
SSL certificate not issuing Ensure your domain's DNS A record points to your server's IP and has propagated. Dokploy uses Let's Encrypt HTTP-01 challenges, so port 80 must be accessible. Check Traefik logs in Dokploy for certificate-related errors.
Learn more about Gogs in our complete overview.
Need a VPS? Hostinger VPS starts at $4.99/mo — perfect for running Gogs.
For more on Docker Compose deployments in Dokploy, see the Dokploy Docker Compose documentation.
App data sourced from selfh.st open-source directory.
Ready to get started?
Get the best VPS hosting deal today. Hostinger offers 4GB RAM VPS starting at just $4.99/mo.
Get Hostinger VPS — $4.99/mo// up to 75% off + free domain included
// related topics
fordnox
Expert VPS reviews and hosting guides. We test every provider we recommend.
// last updated: February 12, 2026. Disclosure: This article may contain affiliate links.