Title: Self-Hosted GitHub Runner with Docker: How-To
URL: https://codemany.com/docs/guides/docker-runner
Description: Run Docker jobs on your own GitHub Actions runner. Learn the setup, how to keep the disk from filling up, and common mistakes to avoid.
All pages as Markdown: https://codemany.com/llms.txt

---

[Home](https://codemany.com/) [Docs](https://codemany.com/docs) [Guides](https://codemany.com/docs#guides)

# Self-hosted GitHub runner with Docker: how to set it up

Run Docker jobs on your own runner, and keep its disk from filling up.

A self-hosted GitHub Actions runner can run Docker jobs if Docker is installed on the machine. Steps that call `docker build` just work. Jobs that use `container:`, service containers or Docker container actions need a Linux runner. Prune old images and build cache, or the disk fills up in weeks.

## Can GitHub Actions use Docker?

Yes. GitHub's hosted Ubuntu runners come with Docker. On a self-hosted runner, Docker is there only if you install it. There are three ways a workflow uses Docker:

- **Docker commands in a step**, like `docker build` or `docker compose up`. These work on Linux and on a Mac with a Docker engine.
- **Container jobs and service containers** (`container:` and `services:`). GitHub runs these only on Linux runners with Docker.
- **Docker container actions**, actions that ship a Dockerfile. These need Linux too.

## How do I run Docker jobs on a self-hosted runner?

1. Install Docker on the runner machine
   On Linux, install Docker Engine. On a Mac, use Docker Desktop or Colima.
2. Let the runner reach Docker
   The runner's user must be able to talk to the Docker socket. Check it as that user: `docker info`.
3. Ask for Docker in the job
   Add a label so the job only lands on runners that have Docker.

```
jobs:
  image:
    runs-on: [self-hosted, Linux, docker]
    steps:
      - uses: actions/checkout@v4
      - run: docker build -t app:${{ github.sha }} .
      - run: docker run --rm app:${{ github.sha }} make test
```

A plain runner doesn't add a `docker` label by itself; you add it when you register the runner. Codemany adds it for you while a Docker engine answers on the machine.

## Can the runner itself run in Docker?

Yes. GitHub publishes a runner image, `actions-runner`, on GitHub Packages; it is the one Actions Runner Controller uses. To run Docker jobs from inside it, you either mount the host's Docker socket or run Docker in Docker. Both give jobs a lot of power over the host, so use them only for code you trust. More: [Docker in Docker on GitHub Actions](https://codemany.com/articles/github-actions-docker-in-docker) and [ARC](https://codemany.com/docs/guides/actions-runner-controller).

## How do I keep a Docker runner's disk from filling up?

Docker keeps every image, volume and layer of build cache until you delete it. On a busy runner that fills the disk in weeks, and jobs fail with "no space left on device". Check what Docker uses, then prune when no job is running:

```
docker system df
docker system prune --all --force
docker builder prune --all --force
```

To stop it coming back, prune once a week with cron and keep what was used in the last 7 days:

```
0 3 * * 0 docker system prune --force --filter "until=168h"
```

Pruning build cache makes the next build start colder. To keep the layers you want, see [Docker layer caching](https://codemany.com/articles/docker-layer-caching-github-actions). Full fix: [self-hosted runner disk full](https://codemany.com/problems/self-hosted-runner-disk-full).

## Common mistakes with Docker runners

- **Adding the runner user to the `docker` group without thinking.** Docker access is as strong as root on that machine. Any workflow can use it.
- **Running public repo jobs on it.** A pull request from a stranger can run `docker run --privileged` on your box. Keep self-hosted runners on private repos ([runner security](https://codemany.com/docs/guides/runner-security)).
- **Leftover containers.** A job that fails halfway can leave containers, networks and volumes running. Use `docker run --rm` and `docker compose down -v` in an `if: always()` step.
- **The wrong CPU type.** An Apple silicon Mac or an Arm server builds `arm64` images by default. Use `docker buildx build --platform linux/amd64` when you deploy to x64.
- **Using `container:` on a Mac runner.** Container jobs and service containers only run on Linux runners. On a Mac, call `docker` in a step instead.
- **No disk plan.** Prune on a schedule, as above, and watch free space.

## Docker jobs with Codemany

- **The `docker` label.** Codemany adds it while a Docker engine answers on the machine, so `runs-on: [self-hosted, codemany, docker]` only lands where Docker works ([runner labels](https://codemany.com/docs/advanced#labels)).
- **On a Mac**, Codemany can install Colima for you, and the **Keep Docker running** setting restarts Docker when it stops. With a separate user per runner, each runner sees only its own containers, images and volumes; privileged containers and host networking are blocked ([Advanced](https://codemany.com/docs/advanced)).
- **On Linux**, host mode uses the machine's own Docker. With a fresh VM or LXD container per job (opt-in), Docker is inside every one and is thrown away after the job ([Machines](https://codemany.com/docs/machines)).
- **Disk.** When disk runs low, Codemany frees space itself, starting with old Docker build cache, unused volumes and old images. Runners wait instead of starting a job that would fail.

## Questions

### Can GitHub Actions use Docker on a self-hosted runner?

Yes, if Docker is installed on the runner machine and the runner's user can reach it. Docker commands work on Linux and Mac runners. Container jobs, service containers and Docker container actions need a Linux runner.

### Can a Mac self-hosted runner run Docker jobs?

Yes, for steps that call `docker`, with Docker Desktop or Colima on the Mac. Jobs that use `container:` or `services:` need a Linux runner.

### Is docker system prune safe on a runner?

Yes, when no job is running. It removes stopped containers, unused images and build cache, so the next build starts colder.

### Should I mount the Docker socket into the runner?

Only for code you trust. With the socket, a job can start any container on the host, which is close to root access.

## Related

Read next: [a self-hosted runner on Linux](https://codemany.com/docs/guides/linux-runner), [single-use runners](https://codemany.com/docs/guides/ephemeral-runners) and [dirty workspaces between jobs](https://codemany.com/problems/dirty-workspace-between-jobs).

[Previous Self-hosted runner on Linux](https://codemany.com/docs/guides/linux-runner)[Next Runners on Hetzner](https://codemany.com/docs/guides/hetzner-runner)

## Site links

- Menu: [codemany home](https://codemany.com/) · [Changelog](https://codemany.com/changelog) · [Download](https://codemany.com/download)
- Documentation: [Overview](https://codemany.com/docs) · [Get started](https://codemany.com/docs/get-started) · [Machines](https://codemany.com/docs/machines) · [Plan & Billing](https://codemany.com/docs/billing) · [Troubleshooting](https://codemany.com/docs/troubleshooting) · [FAQ](https://codemany.com/docs/faq) · [Security & privacy](https://codemany.com/docs/security) · [Self-hosted runner guide](https://codemany.com/docs/guides/self-hosted-runner) · [macOS runner on a Mac mini](https://codemany.com/docs/guides/mac-runner) · [iOS and Xcode builds](https://codemany.com/docs/guides/ios-xcode) · [Self-hosted runner on Linux](https://codemany.com/docs/guides/linux-runner) · [Runners on Hetzner](https://codemany.com/docs/guides/hetzner-runner) · [Single-use runners](https://codemany.com/docs/guides/ephemeral-runners) · [ARC, and without Kubernetes](https://codemany.com/docs/guides/actions-runner-controller) · [GitHub Actions pricing](https://codemany.com/docs/guides/actions-cost) · [Self-hosted runner cost](https://codemany.com/docs/guides/self-hosted-runner-cost) · [GitHub Actions alternatives](https://codemany.com/docs/guides/github-actions-alternatives) · [Runner security](https://codemany.com/docs/guides/runner-security) · [Waiting for a runner](https://codemany.com/docs/guides/waiting-for-runner) · [Articles](https://codemany.com/articles) · [Features](https://codemany.com/features) · [Problems and fixes](https://codemany.com/problems) · [Advanced](https://codemany.com/docs/advanced) · [Compare](https://codemany.com/docs/compare) · [Pricing](https://codemany.com/pricing) · [Privacy Policy](https://codemany.com/privacy)
- Product: [Linux](https://codemany.com/linux) · [Console](https://console.codemany.com/)
- Company: [About](https://codemany.com/about) · [Status](https://codemany.com/status) · [Featured on](https://codemany.com/featured-on) · [Contact](https://x.com/arpwal) · [Terms](https://codemany.com/terms) · [Codemany on X](https://x.com/codemanyhq) · [© 2026 Rainbow Labs Inc.](https://rainbowlabs.xyz)
