Installing Gitea with Docker Compose: A Step-by-Step Guide

Installing Gitea with Docker Compose: A Step-by-Step Guide


2 min read

Gitea is a lightweight, self-hosted Git service that provides an easy-to-use interface, making it an excellent alternative to other popular Git services like GitHub or GitLab. In this article, we will walk you through the process of installing Gitea using Docker Compose, a tool that simplifies the deployment and management of multi-container Docker applications.


Before we begin, ensure that you have the following installed on your system:

  1. Docker

  2. Docker Compose

Step 1: Create a Docker Compose File

First, create a new directory for your Gitea project and navigate to it:

mkdir gitea && cd gitea

Next, create a file named docker-compose.yml in the project directory using your preferred text editor.

Step 2: Define Gitea and Database Services

In the docker-compose.yml file, define the Gitea and database services. In this example, we will use PostgreSQL as the database.

version: '3'

    image: gitea/gitea:latest
    restart: always
      - 3000:3000
      - 222:22
      - ./gitea:/data
      - db

    image: postgres:latest
    restart: always
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=yourpassword
      - POSTGRES_DB=gitea
      - ./postgres:/var/lib/postgresql/data

Step 3: Run Docker Compose

With the services defined, it's time to launch the containers using Docker Compose:

docker-compose up -d

This command will pull the necessary images and create the containers in the background. The -d flag detaches the process, allowing it to run in the background.

Step 4: Access Gitea

Once the containers are up and running, open a web browser and navigate to http://localhost:3000. You should see the Gitea installation page.

Step 5: Configure Gitea

On the Gitea installation page, configure the following settings:

  1. Database Type: PostgreSQL

  2. Host: db:5432

  3. User: gitea

  4. Password: yourpassword

  5. Database Name: gitea

You can customize other settings like the application name, repository root path, and domain as per your requirements. Once you have filled in the necessary information, click on "Install Gitea" to complete the installation process.


You have now successfully installed Gitea using Docker Compose. You can start creating repositories, inviting collaborators, and managing your Git projects with ease.