This is an example of GitHub Actions runner setup with real DinD
-
Clone this repository
-
Copy
.env.example
to.env
, and fill out the required variables as you like2.1 Available environment variables are here
-
Modify docker-compose file as you like
3.1 For example, setting the runner image tag, which exists here
3.2 You can disable container auto-update by removing
com.centurylinklabs.watchtower.scope=actions-runner
label3.3 You can modify how many actions runners to spawn by editing deploy.replicas option
-
Run
dind-actions-runner
with$ docker compose up -d
(Compose v2) or$ docker-compose up -d
-
You can see container logs with
$ docker compose logs -f
(Compose v2) or$ docker-compose logs -f
-
Turn off
dind-actions-runner
with$ docker compose stop
(Compose v2) or$ docker-compose stop
-
Remove/destroy
dind-actions-runner
with$ docker compose down
(Compose v2) or$ docker-compose down
-
That's all you need to know. 🎉
Most setup or example on the Internet, uses something like this:
$ docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock:ro
runner-image:latest
This is fine, and runner container can do Docker stuffs, but the Docker Daemon would be shared with Host machine. Some people like me doesn't like to do this because it clutters the Host's Docker Daemon.
Many people called this Docker-in-Docker (DinD), but in fact it is not true DinD, and I called it Docker-from-Docker or Docker socket binding
Docker itself provides a container image that implements Docker-in-Docker hack: docker:dind
Using that container image, we can spin up a new Docker daemon inside a container, which would be used for GitHub Actions Runner containers.
There are two ways to do this:
- Share Docker socket from DinD container to GitHub Actions Runner containers (Prone to breakdown, and unix permissions issues)
- Make GitHub Actions Runner containers communicate with Docker daemon from DinD container via TCP (Recommended way of controlling remote docker daemon)
This repository use number 2.
* Trivia: Docker-in-Docker also exists in VSCode's Remote - Containers (devcontainer), as a Additional features
: Reference
This setup uses myoung34's runner image (myoung34/docker-github-actions-runner)
I do not provide container images that are used here. They had their own licenses.