DOKPLOY-GUIDE 7 min read fordnox

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

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:

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

  1. In your Dokploy project, navigate to the Domains tab
  2. Click Add Domain and enter your domain (e.g., git.yourdomain.com)
  3. Set the container port to 3000
  4. Enable HTTPS — Dokploy automatically provisions a Let's Encrypt SSL certificate
  5. 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

  1. In Dokploy, go to your project's Deployments tab and click Deploy
  2. Watch the build logs — you should see both gogs and gogs-db containers start
  3. Check the Logs tab for the gogs service. Look for: Listen on 0.0.0.0:3000
  4. Open https://git.yourdomain.com in your browser — you should see the Gogs installation page on first run
  5. During installation, set Database Type to PostgreSQL, Host to gogs-db:5432, User to gogs, Password to your GOGS_DB_PASSWORD, and Database Name to gogs
  6. Set the Domain to git.yourdomain.com, SSH Port to 2222, and Application URL to https://git.yourdomain.com/
  7. 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.

~/self-hosted-app/gogs/dokploy/get-started

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

gogs dokploy docker compose self-hosted git hosting gogs deployment

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.