The main documentation repository for the 🍭☁️
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long. 5.6KB

Gitea with docker-compose

Ensure you have installed docker-compose (see instructions for Raspian) and have added the user you wish to start gitea services to the docker group. To add the current user: sudo usermod -aG docker $USER, or specify the user you desire. On Raspian you can use the default user pi. Re-login, or simply restart to make the changes effective.

This setup uses systemd to run a docker-compose file that starts gitea with a PostgreSQL database. You will also need to define directories to store the contents of the postgres data, and gitea data such as config and git repositories. You will likely want to store these directories on a USB drive, or somewhere other than the Micro SD Card hosting the operating system.

Create data directories

Create the following directories in a convenient location (the paths are up to you). For the rest of the insructions, you will substitute the path any time it appears in curly braces.

Path Example
gitea-data /media/my-usb-drive/gitea/data
gitea-app /media/my-usb-drive/gitea/app/data
gitea-postgres /media/my-usb-drive/gitea/postgres/data
lollipop-home /home/me/lollipop

Ensure the user that is going to run docker-compose to launch the gitea services has both read and write permissions on these directories. To ensure correct ownership is assigned to the application config at {gitea-data}/gitea/conf/app.ini you may need to create an empty file before starting the docker services (touch {gitea-data}/gitea/conf/app.ini).

Define services with docker-compose

Next create the following file in your {lollipop-home} directory of the user that will launch docker-compose. Replace all the values in curly-braces with a path from the table above and create a secretkey for your installation using an string of characters you prefer.


version: "2"


      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=postgres
      - DB_HOST=db:5432
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
      - SECRET_KEY="{secretkey}"
    restart: always
      - gitea
      - {gitea-data}:/data
      - {gitea-app}:/app/gitea/data
      - "3000:3000"
      - "222:22"
      - db

    image: postgres:9.6
    restart: always
      - POSTGRES_USER=gitea
      - POSTGRES_DB=gitea
      - gitea
      - {gitea-postgres}:/var/lib/postgresql/data

The file above instructs docker-compose to launch two services: a gitea server and a postgres server upon which it depends. The postgres image used is a standard image supplied on the main docker registry. We use the gitea image provided by the Lollipop Cloud project. The docker-compose file creates a virtual network for these services to communicate. For further information on the environment variables please see gitea installation with docker and postgres docker documentation.

First time configuration

Now would be a good time to test your installation: docker-compose -f {lollipop-home}/docker-compose.lollipop-gitea.yml up should start your services and gitea should be running on port 3000.

Register an initial account. You will be prompted to confirm initial config. Ensure the database is set to PostgreSQL, the host and port are ‘db:5432’, and enter the password from the docker-compose config above. Set a host name for SSH and HTTPS.

If everything is good, shutdown your services with: docker-compose -f {lollipop-home}/docker-compose.lollipop-gitea.yml down.

Start at boot

Next we will setup systemd to automatically launch gitea on boot, and generally provide a simple interface to manage starting, stopping and checking the status of the services. Create the following file:


Description=Run Lollipop services for gitea

ExecStart=/usr/bin/docker-compose -f docker-compose.lollipop-gitea.yml up
ExecStop=/usr/bin/docker-compose -f docker-compose.lollipop-gitea.yml down


You will need to inform systemd of a new service by running: sudo systemctl daemon-reload. Then you must enable the service by running `sudo systemctl enable lollipop-gitea.service’.

Start the service for the first time by running sudo systemctl start lollipop-gitea.service, and check the status by running sudo systemctl status lollipop-gitea.service'. Reboot your computer withsudo reboot` and your service should start during the boot sequence.

Further configuration has some good examples on how to integrate Matamo, Fathom, create custom labels and more. also has great information on how to further configure Gitea. has great information on how to configure Fail2Ban to help minimize attempts to hack your server.