# Run a Gitea DinD Runner With Rootless Podman


Gitea Runner can use the host's rootless Podman to create job containers. Sharing that same Podman socket with jobs also lets workflows manage the user's other containers, and a job can create a container with a bind mount to read host files that user can access. This socket is a poor fit to share when Gitea and its database run under the same account.

`gitea/runner:latest-dind` runs its own Docker daemon inside the runner container. Rootless Podman manages the outer container; the internal Docker daemon creates job containers and BuildKit builders. No host-installed dockerd is needed.

```text
Host rootless Podman
├── Gitea and other production containers
└── Gitea DinD Runner
    └── Internal Docker
        ├── Job containers
        └── BuildKit containers created by Buildx
```

The [Gitea documentation](https://docs.gitea.com/runner/installation/docker/) says these images are designed for Docker and makes no Podman support claim. The configuration below works on x86_64 Arch Linux: `setup-qemu`, `setup-buildx` and `build-push` all run normally.

## 1. Prerequisites

Install Podman with Quadlet support and make sure the current user can run `podman run`. An administrator must enable linger for user services to keep running after logout:

```shell
sudo loginctl enable-linger "$USER"
mkdir -p ~/pod/gitea-runner
cd ~/pod/gitea-runner
```

The examples use the host user `nite` and the deployment directory `/home/nite/pod/gitea-runner`. Change the absolute paths for a different account.

Obtain a runner registration token from the appropriate instance, organization, or repository settings in Gitea, then create `runner.env`:

```dotenv
GITEA_RUNNER_REGISTRATION_TOKEN=replace-with-registration-token
```

```shell
chmod 600 runner.env
```

## 2. Runner configuration

Create `config.yaml`:

```yaml
log:
  level: info
runner:
  file: /data/.runner
  capacity: 1
  envs: {}
  timeout: 3h
  shutdown_timeout: 30s
  labels:
    - ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest
    - ubuntu-24.04:docker://docker.gitea.com/runner-images:ubuntu-24.04
    - ubuntu-22.04:docker://docker.gitea.com/runner-images:ubuntu-22.04
cache:
  enabled: false
container:
  privileged: false
  options: ""
  valid_volumes: []
  docker_host: unix:///var/run/docker.sock
  force_pull: false
  require_docker: true
  docker_timeout: 120s
metrics:
  enabled: false
```

`container.docker_host` points to the Docker socket inside the runner container. The runner uses it to create jobs and exposes this internal socket to their Docker CLI.

Keep labels in this file rather than overriding them with `GITEA_RUNNER_LABELS`. `container.privileged` applies to job containers; it is separate from the outer runner's `--privileged` in the next section. Leave the cache disabled while validating the build path.

## 3. Quadlet configuration

Create `gitea-runner.container`:

```ini
[Unit]
Description=Gitea DinD runner on rootless Podman
After=network-online.target
Wants=network-online.target

[Container]
Image=docker.io/gitea/runner:latest-dind
ContainerName=gitea-runner-dind
PodmanArgs=--privileged
Environment=GITEA_INSTANCE_URL=https://gitea.example.com
Environment=GITEA_RUNNER_NAME=podman-dind
Environment=CONFIG_FILE=/etc/gitea-runner/config.yaml
EnvironmentFile=/home/nite/pod/gitea-runner/runner.env
Volume=gitea-runner-dind-data:/data
Volume=gitea-runner-dind-docker:/var/lib/docker
Volume=/home/nite/pod/gitea-runner/config.yaml:/etc/gitea-runner/config.yaml:ro

[Service]
Restart=always
RestartSec=10s
TimeoutStartSec=180
TimeoutStopSec=90

[Install]
WantedBy=default.target
```

Replace the instance URL. Install this definition as a regular user's Quadlet; do not start it with `sudo systemctl`.

The bundled dockerd runs as container root while the outer Podman container stays rootless. Do not add `User=1000` or `UserNS=keep-id`, and do not mount the host Podman socket. `latest-dind-rootless` is a different image that starts another rootless Docker environment internally and is not interchangeable with this configuration.

The two named volumes hold runner registration and internal Docker data. Replacing the container needs neither a new registration nor a re-pull of every job image. For production, pin the image to a tested tag or digest instead of following `latest-dind`.

## 4. Install and start

Create `reload.sh`:

```bash
#!/usr/bin/env bash
set -euo pipefail

source_dir="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
unit_dir="${XDG_CONFIG_HOME:-${HOME}/.config}/containers/systemd"

for file in gitea-runner.container config.yaml runner.env; do
    test -f "${source_dir}/${file}" || {
        printf 'Missing required file: %s\n' "${source_dir}/${file}" >&2
        exit 1
    }
done

chmod 0600 "${source_dir}/runner.env"
install -d "${unit_dir}"
install -m 0644 "${source_dir}/gitea-runner.container" "${unit_dir}/gitea-runner.container"
systemctl --user daemon-reload
printf 'Definition reloaded; service not restarted.\n'
```

Start the runner for the first time:

```shell
chmod +x reload.sh
podman pull docker.io/gitea/runner:latest-dind
podman volume create gitea-runner-dind-data
podman volume create gitea-runner-dind-docker
./reload.sh
systemctl --user start gitea-runner.service
journalctl --user -fu gitea-runner.service
```

When migrating from a runner that shares the host socket, wait for its jobs to finish before stopping it, otherwise both runners claim jobs with the same labels. Do not mount the old runner's data directory into the new container.

Once the log reports `Docker is ready` and `declare successfully`, trigger a build in Gitea. After later configuration changes, run `./reload.sh`, wait for active jobs to finish, then restart:

```shell
systemctl --user restart gitea-runner.service
```

## 5. Isolation boundaries

The internal `docker ps` lists only DinD containers, not the host's Gitea or database. A job asking the internal Docker daemon to mount `-v /:/host` gets the runner container's filesystem.

This boundary holds only while no extra host directories or management sockets are mounted, and rootless `--privileged` still shares the host kernel. Use separate runners and storage for repositories with different trust levels.


---

> Author: Nite  
> URL: https://www.nite07.com/en/posts/gitea-runner-rootless-podman/  

