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.
Even though you can think of Fly.io as a “container”-service hosting platform, it’s actually using Firecracker micro-VMs to run your service. They (“transmogrify”)[https://fly.io/blog/docker-without-docker/] Docker images into the micro-VMs they run. This means, it’s much easier to run a docker daemon, as you don’t need to worry about the implications of running the docker daemon inside of a docker container.
After creating a whole Docker image with the docker daemon inside of it, and getting it working on Fly, I found that Fly already made one, and it’s much more succinct than mine. So this post will reference their implementation instead, as 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 ceate 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. So instead of trying to map an existing service into a fly.toml file, you could just use an existing docker-compose.yml.
Next steps could include establishing a wireguard tunnel to your service and having the docker client on your local machine connect to the daemon over the tunnel.