Getting Started with Gitea Using Docker
Introduction
Gitea is a lightweight, self-hosted Git service similar to GitHub and GitLab. It allows you to manage your code repositories, issues, and more. This guide will walk you through setting up Gitea with Docker using PostgreSQL as the database, helping you get started with your own Git hosting platform.
Prerequisites
Ensure you have the following installed:
- Docker: Install Docker
Setting Up Gitea with Docker
1. Create a Docker Compose File
Start by creating a docker-compose.yml
file with the following content:
version: "3"
services:
server:
image: gitea/gitea:latest
container_name: "gitea"
restart: unless-stopped
environment:
GITEA__database__DB_TYPE: postgres
GITEA__database__HOST: postgresql:5432
GITEA__database__NAME: gitea
GITEA__database__USER: gitea
GITEA__database__PASSWD: gite@12345
APP_NAME: Clint Masden Gitea
RUN_USER: administrator
volumes:
- ./data:/data
- ./config:/etc/gitea
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "8001:3000"
- "8002:2222"
depends_on:
- postgresql
postgresql:
image: postgres:latest
container_name: "gitea-postgres"
restart: unless-stopped
environment:
POSTGRES_DB: gitea
POSTGRES_USER: gitea
POSTGRES_PASSWORD: gite@12345
volumes:
- ./postgres:/var/lib/postgresql/data
2. Run Gitea
Launch the Gitea service by running:
docker-compose up -d
This will spin up both the Gitea and PostgreSQL containers.
3. Initial Setup
Once the containers are running:
- Access Gitea: Go to
http://your-server-ip:8001
in your web browser. - Login: Use the default admin username
administrator
and the email addressexample@gmail.com
to complete the initial setup. - Create a Repository: After logging in, you can create a new repository by navigating to the “New Repository” section.
Additional Configuration and Usage
- Rootless Installation: Gitea can be configured to run in a rootless mode for better security. Check out the Gitea rootless installation guide for more details.
- Comparisons and Alternatives: Explore differences between Gitea and alternatives like Gogs in the comparison guide.
Resources and References
Conclusion
You’ve now set up Gitea with Docker, ready to host and manage your Git repositories. This configuration provides a solid foundation for your personal or team projects. Consider exploring additional features such as CI/CD integration, webhooks, and custom themes to enhance your Gitea instance further.