Docker compose on fly.io: proof-of-concept

Wonderful, or terrible?

2 Likes

Terriderful :wink:

I was pondering this recently. Perhaps adding more services like DB can help illustrate the point.

I have been looking into this on and off for several months now. Here was my previous take: Docker Compose support - #2 by rubys

I notice that your docker-compose.yml doesn’t have a build step, so that should mostly work fine. Building is the hard problem.

Another issue bypassing the build is that the fly machines seem to have a disk sized by the image so I had to mount a volume and move the docker directory to it in order to get larger image pulls to work. You should be able to build and pull beforehand though by pulling inside the builder. The issue with that is the default builders are docker run without elevated --privilege which is necessary for docker in docker. So it’ll need an image built with a modified builder or a custom imsge which I imagine fly must support somehow?

OK, so custom build is the way…

# Use moby to use insecure flags
docker buildx create --driver-opt image=moby/buildkit:master  \     
                     --use --name insecure-builder \
                     --buildkitd-flags '--allow-insecure-entitlement security.insecure'
docker buildx use insecure-builder

# Build it and push to flyio registry
sudo docker buildx build . --platform linux/amd64 --allow security.insecure --push -t registry.fly.io/docker-compose-on-fly:v2

...

# dockerfile new first line:
# syntax = docker/dockerfile:experimental
...
# You'll need to install docker cli inside the Dockfile first, then...
# This caches the pulled images inside the container image
RUN --security=insecure sh -c "dockerd & sleep 5 && docker compose pull"

Mine ended up as a 17 gigabyte image though, lol, which exceeded the 8gb max, so when I deployed I got:

2024-10-09T03:36:41.875 runner[1781e67a941058] ewr [info] Pulling container image registry.fly.io/docker-compose-on-fly:v2

2024-10-09T03:40:00.081 runner[e2867095b61028] ewr [error] Not enough space to unpack image, possibly exceeds maximum of 8GB uncompressed


So more work before this is practice advice.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.