I started setting up CI in my homelab a few nights ago. Forgejo has a built-in CI system modeled after GitHub Actions — you write a workflow file, deploy a runner container, and it picks up jobs when you push code.
The setup wasn’t the hard part. The hard part was that it forced me to actually think about Docker’s architecture in a way I’d been quietly avoiding. Specifically: what happens when you have more than one Docker daemon running, and how do you keep track of which one is doing what?
I thought I understood Docker well enough. Client/server, daemon, socket. I could say those words. But I couldn’t reason through them when the abstractions started leaking.
How Forgejo Actions works
You deploy a runner container that polls your Forgejo instance for jobs. Push code, trigger a workflow, runner picks it up. Straightforward.
The interesting part is how the runner executes those jobs. When your CI runner is itself a container, you have to decide where job containers get created. That decision changes everything downstream.
Two ways to run CI jobs from a container
Docker-out-of-Docker (DooD)
The runner mounts the host’s Docker socket (/var/run/docker.sock) and talks directly to the host daemon. When a CI job spins up a container, it lands on the host — right alongside your other services.
This works fine. But it means CI jobs share the same Docker world as everything else: same networks, same volumes, same image cache. If you’re running anything sensitive, that shared surface area is worth thinking about.
Docker-in-Docker (DinD)
The runner uses a separate Docker daemon running inside its own container. CI jobs talk to that inner daemon. From the host’s perspective, there’s one container (the DinD daemon), and everything inside it is walled off.
This sounded cleaner to me. Isolated builds, no cross-contamination with production services, clear boundaries.
But it also means you now have two Docker daemons. And that’s where things got confusing.

The thing I didn’t internalize
Docker is client/server. The docker CLI is a client that talks to a daemon, usually over /var/run/docker.sock or a TCP port.
Here’s what I knew but hadn’t internalized: the client only talks to one daemon at a time. That daemon owns everything — containers, images, networks, volumes. There’s no shared global state between daemons.
When you run docker ps, you’re not asking “what containers exist on this machine?” You’re asking “what containers does this specific daemon know about?”
Once I had both the host daemon and a DinD daemon running, I kept tripping over this. I’d create a network on the host and wonder why a container inside DinD couldn’t see it. I’d build an image on one daemon and get confused when docker images on the other showed nothing.
None of it was random. I just wasn’t tracking which daemon I was talking to.
DOCKER_HOST is the invisible context switch
The Docker client decides which daemon to talk to based on the DOCKER_HOST environment variable. If it’s unset, you get the local socket (the host daemon). If it points to a DinD daemon’s TCP port, you’re in a completely different Docker universe.
There’s no prompt change. No indicator. You just silently switch contexts.
Once I understood that, most of my confusion went away. Docker wasn’t doing anything weird — I was issuing commands without being clear about which Docker I was talking to.
Two questions that made everything click
Before touching any config, I started forcing myself to answer two questions:
- Which daemon creates the CI job containers?
- When a CI job runs
docker buildordocker run, which daemon does it talk to?
For DinD:
- The DinD daemon creates job containers.
- Jobs talk to the DinD daemon — that’s where they live.
For DooD:
- The host daemon creates job containers.
- Jobs talk to the host daemon — the socket is mounted in.
That’s the whole mental model. Everything else — volume mounts, network config, image caching — flows from those two answers.
What actually changed for me
I thought knowing “Docker is client/server” was sufficient understanding. It wasn’t.
What I needed was: the daemon you’re talking to defines your reality. Containers, networks, images — they don’t float around in some abstract Docker-land. They exist in a specific daemon’s state. And in a CI setup where you’re intentionally isolating build environments, you’re almost certainly dealing with multiple daemons.
If you don’t track which one you’re in, you end up copying config without understanding it and having no idea which layer is wrong when something breaks. The configuration for Forgejo Actions with DinD isn’t complicated — you’re just making explicit which daemon creates containers and which daemon they talk to. But without the mental model, every example you find online looks like magic.