Gitea is a lightweight, open-source version control platform that is designed to be easy to install and use. One way to install and run Gitea is by using Docker, which allows you to quickly and easily set up a Gitea instance without having to worry about dependencies or other system-level configurations. In this article, we will explain how to install Gitea using Docker on Ubuntu 22.04.
Before you begin, make sure that you have Docker and Docker Compose installed on your Ubuntu server. You can check if Docker is installed by running the following command:
sudo docker --version
If Docker is not installed, you can install it using the following command:
sudo apt-get install docker.io
Once Docker is installed, you can check if Docker Compose is installed by running the following command:
sudo docker-compose --version
If Docker Compose is not installed, you can install it using the following command:
sudo apt-get install docker-compose
Once Docker and Docker Compose are installed, you can proceed with installing Gitea. To do this, you need to create a new directory where Gitea will store its data and configuration files. For example, you can create a gitea
directory in the /srv
directory using the following command:
sudo mkdir -p /srv/gitea/conf /srv/gitea/data /srv/gitea/log
Next, you need to create a docker-compose.yml
file in the /srv/gitea
directory. You can use a text editor to create this file, or you can use the following command to create it using the touch
command:
sudo touch /srv/gitea/docker-compose.yml
Once the docker-compose.yml
file is created, you can add the following content to it, which will define the Docker containers and settings for Gitea:
version: "3.1"
services:
gitea:
image: 'gitea/gitea:latest'
restart: always
hostname: 'gitea.example.com'
environment:
- USER_UID=1000
- USER_GID=1000
ports:
- '3000:3000'
volumes:
- '/srv/gitea/conf:/data/gitea/conf'
- '/srv/gitea/data:/data/gitea/data'
- '/srv/gitea/log:/data/gitea/log'
This docker-compose.yml
file defines a single Docker container for Gitea, using the latest Gitea image. It specifies the hostname for the Gitea instance, as well as the UID and GID that should be used for the Gitea user. It also maps the necessary ports and volumes, so that Gitea can access its configuration, data, and log files.
Once you have created the docker-compose.yml
file, you can use Docker Compose to start the Gitea container by running the following command:
sudo docker-compose up -d
This will start the Gitea container in the background, using the settings specified in the docker-compose.yml
file. Once the container is running, you can visit the hostname that you specified in the docker-compose.yml
file (in this case, http://gitea.example.com
) to access the Gitea web interface.
The first time you visit the Gitea web interface, you will be prompted to set up the initial administrator account. This is the default administrative user for Gitea, and you will use this user to log in and manage your Gitea instance. Once you have set up the initial administrator account, you can log in to Gitea and start using it to manage your code repositories.
In conclusion, installing Gitea using Docker on Ubuntu 22.04 is a simple and convenient way to set up a Gitea instance on your server. By using Docker, you can quickly and easily get Gitea up and running, without having to worry about dependencies or system-level configurations. This makes it a useful option for developers and teams who want to use Gitea for managing and collaborating on code repositories.