Sub topic 10
Choosing a container mode
This chapter assumes you have installed the controller and a runner scale set with Helm, as in the earlier chapters. You should be comfortable reading a values file, running kubectl against the runner namespace, and writing a workflow with runs-on. Here you decide how the runner pod handles containers, and you learn what that choice changes.
Why the container mode matters
Many workflows use containers. They run docker build, start a services: database for tests, use a container: job, or call an action that is itself a Docker image. A plain runner pod has no Docker daemon, so those steps fail unless you choose a container mode.
The mode is set with containerMode.type in the scale set values file. Three settings exist:
- Unset: the runner pod contains only the runner container. Steps run directly in it, and anything that needs Docker fails.
dind: Docker-in-Docker. The pod gets a second container running a Docker daemon.kubernetes: the runner uses Kubernetes pods instead of Docker to run job containers, service containers, and container actions.
Recent chart versions also add a kubernetes-novolume mode that avoids the shared work volume. Check your chart version's values.yaml before relying on it. This chapter covers dind and kubernetes, which are the two most common choices.
dind mode
In dind mode the chart adds a dind container to every runner pod. This container runs the Docker daemon. The runner container and the daemon share the Docker socket and the work directory through volumes, so the runner's docker commands reach the sidecar daemon.
The configuration is short:
githubConfigUrl: "https://github.com/<your-org>/<your-repo>"
githubConfigSecret: pre-defined-secret
minRunners: 0
maxRunners: 10
containerMode:
type: "dind"A workflow on this scale set can use Docker as it would on a GitHub-hosted runner:
name: dind build
on: workflow_dispatch
jobs:
build:
runs-on: arc-runner-set
steps:
- uses: actions/checkout@v4
- name: Build an image
run: |
cat > Dockerfile <<'EOF'
FROM alpine:3.20
RUN echo "built inside dind"
EOF
docker build -t demo:${{ github.sha }} .
- name: Run it
run: docker run --rm demo:${{ github.sha }} echo okStrengths of dind
- Workflows written for hosted runners usually work unchanged, including
docker build,docker compose, andservices:. - It needs no extra storage class or persistent volume.
- Each pod has its own daemon, so concurrent jobs do not share image or container state.
Costs of dind
- The
dindcontainer runs as privileged. A job that escapes the container can reach the node's kernel. Treat this as a real security boundary question, not a formality. - Every pod starts with an empty image cache. Pulling base images and rebuilding layers on every job costs time and bandwidth.
- The daemon uses memory and CPU that the runner container's limits do not cover. Size the whole pod, not only the runner container.
- Clusters that forbid privileged pods through Pod Security Admission or a policy engine will reject the pod.
kubernetes mode
In kubernetes mode there is no Docker daemon. The runner uses the runner container hooks, a set of scripts that replace Docker calls with Kubernetes API calls. When a job declares container:, services:, or uses a container action, the hook creates a separate pod in the same namespace for each one. These pods are called workflow pods.
The runner and the workflow pods must see the same work directory, so the chart needs a volume. You configure it with kubernetesModeWorkVolumeClaim:
githubConfigUrl: "https://github.com/<your-org>/<your-repo>"
githubConfigSecret: pre-defined-secret
minRunners: 0
maxRunners: 10
containerMode:
type: "kubernetes"
kubernetesModeWorkVolumeClaim:
accessModes: ["ReadWriteOnce"]
storageClassName: "standard"
resources:
requests:
storage: 1GiReplace standard with a storage class that exists in your cluster. The chart creates a claim for each runner pod, and it goes away with the pod. The chart also creates a service account and role for the runner, so it can create and delete pods, read pod logs, and exec into pods in its namespace.
A workflow for this mode puts the job inside a container:
name: kubernetes mode test
on: workflow_dispatch
jobs:
test:
runs-on: arc-runner-set
container:
image: node:20-alpine
services:
redis:
image: redis:7
steps:
- uses: actions/checkout@v4
- run: node --versionHere the job's steps run in a workflow pod built from node:20-alpine, and redis runs in a second workflow pod. You can watch them appear with kubectl get pods -n arc-runners --watch.
Strengths of kubernetes mode
- No privileged container is needed, so the pod passes stricter admission policies.
- Job and service containers are ordinary pods. They show up in
kubectl, count against namespace quotas, and honor the cluster's scheduling and network rules. - Resource accounting is cleaner, because each container is a pod with its own requests and limits.
Costs of kubernetes mode
- Docker is not available. A step that runs
docker buildordocker runfails because there is no daemon. Build images with a daemonless tool such as Kaniko or Buildah, or send builds to a separate build service. - The runner hooks require a job container by default. If a job has no
container:and no container action, it can fail with an error saying a job container is required. You can disable the check by settingACTIONS_RUNNER_REQUIRE_JOB_CONTAINERto"false"on the runner container, but then steps run in the runner container itself. - You need a storage class that can provision the work volume quickly. Slow provisioning adds seconds or minutes to every job start.
- With
ReadWriteOncevolumes, workflow pods must run on the node that has the volume attached. A full node can leave a workflow pod waiting while the runner pod is already running. - Behavior differs from hosted runners in small ways, such as how volume mounts and ports map. Expect some workflows to need edits.
Comparing the modes
| Question | dind | kubernetes |
|---|---|---|
| Can steps run `docker build`? | Yes | No |
| Privileged container needed? | Yes | No |
| Extra storage needed? | No | Yes, a work volume per runner |
| Where do job containers run? | Inside the pod's daemon | As separate pods in the namespace |
| Image cache between jobs | None by default | Per node image cache from the container runtime |
| Changes needed to hosted-runner workflows | Few | Often some |
The image cache row needs explanation. In kubernetes mode the workflow pods pull images through the node's container runtime, so a second job on the same node can reuse an image the first one pulled. In dind mode each pod's daemon starts empty.
Making the choice
The decision depends mostly on whether your workflows build images and on what your cluster allows.
Some practical rules follow from this:
- If most workflows run
docker buildand you can allow privileged pods in a dedicated namespace, start withdind. - If your platform team forbids privileged pods, use
kubernetesand move image builds to a daemonless tool. - If you need both, run two scale sets with different installation names and let each workflow pick one in
runs-on. This also keeps the privileged pods in their own namespace.
Checking which mode you are in
Inspect a running runner pod to confirm what the chart built:
kubectl get pods -n arc-runners
kubectl get pod <runner-pod-name> -n arc-runners \
-o jsonpath='{.spec.containers[*].name}{"\n"}'In dind mode the second command lists runner and dind. In kubernetes mode it lists only runner, and kubectl get pvc -n arc-runners shows one claim per runner pod. If a job in kubernetes mode hangs, run kubectl describe pod on the workflow pod and look at the events. Volume attach errors and unschedulable messages are the usual causes.
Exercise
A team's workflows run docker build and docker compose up, and the cluster has a dedicated namespace where privileged pods are allowed. Which container mode fits, and what is the main security cost? Also, if the cluster later bans privileged pods, what must change in their workflows under kubernetes mode?
Show answer
Use dind, because it provides a Docker daemon that supports docker build and docker compose without workflow changes. The cost is that the dind container is privileged, so a job that escapes its container can reach the node. Under kubernetes mode there is no Docker daemon, so they must replace docker build with a daemonless builder such as Kaniko or Buildah, and replace docker compose with services: containers or separate pods. Jobs would also need a container: unless the require-job-container check is disabled.
Exercise
You switch a scale set to kubernetes mode and a job stays queued after the runner pod is running. The runner pod is healthy. Name two things to check.
Show answer
Check the workflow pod with kubectl describe pod, because it may be unschedulable. With a ReadWriteOnce work volume the pod must land on the runner's node, which may be full. Also check the persistent volume claim with kubectl get pvc -n arc-runners, since a missing or wrong storageClassName leaves the claim pending and the job cannot start.