Skip to content
zefıly
← All posts

Self-hosting Gitea: your own Git server with Docker

4 min read

Gitea is a light Git hosting service you can run on a small server. How to start it with Docker, the settings to get right on the installation page, how to stop strangers from registering, whether to use SSH, and how to back it up.

Gitea gives you what most teams use a Git host for: repositories, pull requests, issues, a package registry and CI (Gitea Actions). It is one small program, and it runs well on a server that could not carry GitLab.

We tested the commands here on 12 November 2026 with the official gitea/gitea:latest image.

In short

  • One container, one volume (/data). SQLite by default, no database server needed.
  • Our idle container used about 85 MB of memory.
  • Set ROOT_URL to your public HTTPS address before the first start.
  • The first registered user becomes the administrator. Register at once, then close registration.
  • Decide about SSH: HTTPS with access tokens is simpler, SSH needs its own port.
  • Back up with gitea dump or by copying the volume.

1. Start the container

docker volume create gitea_data

docker run -d --name gitea --restart unless-stopped \
  -p 127.0.0.1:3000:3000 \
  -e GITEA__server__ROOT_URL=https://git.example.com/ \
  -e GITEA__server__DISABLE_SSH=true \
  -v gitea_data:/data \
  docker.io/gitea/gitea:latest

Settings can be given as environment variables in the form GITEA__section__KEY. Gitea writes them into its configuration file on start. We checked the result in /data/gitea/conf/app.ini:

ROOT_URL = https://git.example.com/
DISABLE_SSH = true
  • ROOT_URL is the address Gitea puts into clone URLs, emails and links. If it is wrong, the clone button shows an address nobody can reach.
  • DISABLE_SSH=true hides SSH clone URLs. We explain the choice below.
  • For production, replace :latest with a fixed version tag and update on purpose.

2. Reverse proxy

server {
    server_name git.example.com;
    client_max_body_size 512M;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

client_max_body_size matters: a git push over HTTPS sends the data as one request, and nginx's default limit of 1 MB rejects anything larger with 413 Request Entity Too Large.

3. The installation page

The first visit shows the Installation page. Most values are already right. Check these:

  • Database type: SQLite3 is the default and fine for a team. Choose PostgreSQL or MariaDB if you expect many users.
  • Server domain and base URL: must match your public address.
  • Administrator account: fill it in here. If you leave it empty, the first user who registers becomes the administrator.

Open the site and finish this page immediately after starting the container. Until you do, anybody who finds the address can complete the installation.

4. Close registration

By default anybody can create an account on your Gitea. For a private server, turn that off. Add to the container:

-e GITEA__service__DISABLE_REGISTRATION=true

and create further users yourself in the site administration. If the repositories are private too, also set:

-e GITEA__service__REQUIRE_SIGNIN_VIEW=true

so that visitors who are not logged in see nothing.

5. HTTPS or SSH for Git?

HTTPS works through the web server you already have. Users create an access token in their Gitea settings and use it as the password. Nothing else to open.

SSH is what many developers are used to, but the container's SSH server needs its own port on the host, and port 22 is already taken by the server's own SSH. You would publish it on another port (for example 2222), open that port in the firewall, and tell Gitea about it.

For a small team, start with HTTPS and tokens. Add SSH later if somebody misses it.

6. What is in the volume

git  gitea  ssh
  • git/: the repositories.
  • gitea/: the configuration (conf/app.ini), the SQLite database, attachments, avatars, packages, logs.
  • ssh/: the container's SSH host keys.

app.ini contains secrets (SECRET_KEY, INTERNAL_TOKEN). Treat backups of this volume as confidential.

7. Backups

Gitea has its own dump command, which writes the database, the repositories and the configuration into one archive:

docker exec -u git -w /tmp gitea gitea dump -c /data/gitea/conf/app.ini

Or stop the container and copy the whole volume:

docker stop gitea
docker run --rm -v gitea_data:/data -v "$PWD":/backup alpine \
  tar czf /backup/gitea-$(date +%F).tar.gz -C /data .
docker start gitea

Either way, copy the result off the server. Every developer's clone is a copy of the code, but not of issues, pull requests and settings.

8. Updates

docker pull docker.io/gitea/gitea:<new version>
docker stop gitea && docker rm gitea
# run the same docker run command with the new tag

Gitea migrates its database on start. Back up first; going back to an older version after a migration means restoring that backup.

With Zefily

Gitea is a one-click app in Zefily: a rootless container under the site's own Linux user, on 127.0.0.1 behind the web server with HTTPS, with ROOT_URL set to your domain and its data in a volume that survives updates. Git over SSH is off; you use HTTPS. The site starts behind a password until you have finished the installation page. See Container apps.

Frequently asked questions

How much server does Gitea need?

Little. Our idle Gitea container used about 85 MB of memory, and it runs with SQLite without a database server.

Who becomes the Gitea administrator?

The account entered on the installation page, or else the first user who registers. Finish the installation right after starting the container.

How do I disable registration in Gitea?

Set GITEA__service__DISABLE_REGISTRATION=true (DISABLE_REGISTRATION in the service section of app.ini) and restart.

Why does git push fail with 413 behind nginx?

nginx limits request bodies to 1 MB by default. Raise client_max_body_size in the site's server block.

Do I need SSH for Gitea?

No. Git over HTTPS with an access token works through your web server. SSH needs an extra port published from the container.

See Containers for running your own images with Zefily.

More posts

Black Friday & Cyber Monday

Before you go: lifetime plans are on sale

Pay once for a lifetime plan, or get 30% off the first year of any yearly plan.

Only 100 lifetime plans per plan. When they are gone, they are gone.

See the campaign

Amazing November

See the campaign →