Files
act_runner/examples/vm/rootless-docker.md
silverwind 1d6c6ffef9 enhance: improve config, comment out values in example file (#1145)
`config.example.yaml` now has every value commented out, as gitea's `app.example.ini` does, so it documents each option with its default instead of imposing it. Copying it no longer pins values the runner would otherwise pick, and a changed default reaches configs that never named the option.

`config init` writes the file to configure: a header comment and no option, so every option keeps its default. It refuses to overwrite an existing config without `--force`, and writes `config.yaml` in the working directory when `-c` is absent.

`config set`, `add` and `remove` keep such a file readable. Comments go back to the indentation they were written at, which the encoder drops for a comment block that has no key below it, and a file of only comments keeps its text instead of being emptied by the first edit.

Also rewrote the config docs sections for clarity.

Reviewed-on: https://gitea.com/gitea/runner/pulls/1145
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: bircni <bircni@icloud.com>
Co-authored-by: silverwind <me@silverwind.io>
2026-08-06 05:15:32 +00:00

2.9 KiB

Using Rootless Docker withgitea-runner

Here is a simple example of how to set up gitea-runner with rootless Docker. It has been created with Debian, but other Linux should work the same way.

Note: This procedure needs a real login shell -- using sudo su or other method of accessing the account will fail some of the steps below.

As root:

  • Create a user to run both docker and gitea-runner. In this example, we use a non-privileged account called rootless.
 useradd -m rootless
 passwd rootless
 apt-get install -y uidmap # Not mentioned but needed for docker rootless.
  • Install docker-ce

  • (Recommended) Disable the system-wide Docker daemon

    systemctl disable --now docker.service docker.socket

As the rootless user:

for f in ./.bashrc.d/*.bash; do echo "Processing $f file..."; . "$f"; done
  • Create the .bashrc.d directory mkdir ~/.bashrc.d
  • Add the following lines to the /home/rootless/.bashrc.d/rootless-docker.bash:
export XDG_RUNTIME_DIR=/home/rootless/.docker/run
export PATH=/home/rootless/bin:$PATH
export DOCKER_HOST=unix:///run/user/$(id -u)/docker.sock
  • Reboot. Ensure that the Docker process is working.
  • Create a directory for saving gitea-runner data between restarts

mkdir /home/rootless/gitea-runner

  • Register the runner from the data directory
 cd /home/rootless/gitea-runner
 gitea-runner register
  • Write a gitea-runner configuration file in the data directory. Edit the file to adjust for the system, gitea-runner config generate documents every option.
 gitea-runner config init --config /home/rootless/gitea-runner/config
  • Create a new user-levelsystemd unit file as /home/rootless/.config/systemd/user/gitea-runner.service with the following contents:
 Description=Gitea Actions runner
 Documentation=https://gitea.com/gitea/runner
 After=docker.service

 [Service]
 Environment=PATH=/home/rootless/bin:/sbin:/usr/sbin:/home/rootless/bin:/home/rootless/bin:/home/rootless/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
 Environment=DOCKER_HOST=unix:///run/user/1001/docker.sock
 ExecStart=/usr/bin/gitea-runner daemon -c /home/rootless/gitea-runner/config
 ExecReload=/bin/kill -s HUP $MAINPID
 WorkingDirectory=/home/rootless/gitea-runner
 TimeoutSec=0
 RestartSec=2
 Restart=always
 StartLimitBurst=3
 StartLimitInterval=60s
 LimitNOFILE=infinity
 LimitNPROC=infinity
 LimitCORE=infinity
 TasksMax=infinity
 Delegate=yes
 Type=notify
 NotifyAccess=all
 KillMode=mixed

 [Install]
 WantedBy=default.target
  • Reboot

After the system restarts, check that thegitea-runner is working and that the runner is connected to Gitea.

 systemctl --user status gitea-runner
 journalctl --user -xeu gitea-runner