Instead of Docker-in-Docker, what about Docker-on-Fly?

Running the docker daemon on a "serverless" hosting platform

In my ever-ending quest to do things that are probably not the best idea that aren't a part of a usual use-case, I wanted to see if I could run a docker daemon on Fly.io.

Fly.io uses Firecracker micro-VMs to run services. It "transmogrifies" Docker images for those micro-VMs. This avoids running the Docker daemon inside another Docker container.

After creating a whole Docker image with the Docker daemon and getting it working on Fly, I found that Fly had already made one. Their version is much more succinct than mine, so this post uses it instead. I suspect mine will never see the light of day.

# first clone the repo
git clone https://github.com/fly-apps/docker-daemon.git docker-on-fly
# then enter the directory
cd docker-on-fly
# --build-only because we need to create a volume
fly launch --build-only
# creating a volume with 50gb of storage
fly volumes create data --size 50 --region ams
# run the service
fly deploy
# ssh into the machine (this example runs a container)
fly ssh console -C "docker run --rm hello-world"

You can now do some interesting things on there such as running entire services with docker compose. Instead of translating a docker-compose.yml file into fly.toml, the service can use the existing Compose file.

Using Compose avoids translating the service definition, but it replaces that work with a Docker daemon, a persistent volume, and a network path to maintain. A next step would be a WireGuard tunnel that lets the local Docker client connect to the daemon.