Gitea: self-hosted Git service with Docker Compose

Gitea is a lightweight Git hosting service with pull requests, issues and CI. How to install it with Docker Compose on your own server.

Gitea is a Git hosting service in a single binary: repositories, pull requests, issues, a package registry and Gitea Actions for CI. It needs far fewer resources than GitLab, which makes it a common choice for a home server or a small team.

What you need

  • A server with Docker and the Compose plugin
  • Free ports 3000 for the web interface and 222 for SSH, or other ports of your choice

Install

Create a folder and a docker-compose.yml. This is the basic setup from the Gitea documentation, with the built-in SQLite database:

networks:
  gitea:
    external: false

services:
  server:
    image: docker.gitea.com/gitea:28.3.0
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "222:22"
  • The image tag is the release that was current on the day this post was written. Check the releases page and use the latest one.
  • USER_UID and USER_GID should match the user on the host that owns the ./gitea folder.
  • 222:22 exposes Git over SSH on port 222 of the host, so it does not clash with the server’s own SSH.

Start it:

docker compose up -d

First run

Open http://<host>:3000. The installation page asks for the database (leave SQLite for a small install), the base URL and the SSH port. Set the base URL to the address people will really use, and the SSH port to 222 so that clone links are correct.

The first user you register becomes the administrator.

SQLite is fine for one person or a small team. The documentation also has compose examples with PostgreSQL and MySQL for larger installs.

Backup

Repositories, the database and the configuration are all in the ./gitea folder.

Updating

Change the image tag to the new release, then:

docker compose pull && docker compose up -d