Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
Using the Fly Docker registry#
Fly.io lets you deploy Docker containers that will be compiled as a Firecracker VM and run in locations around the world.
Fly offer a number of ways to build and deploy apps. For many frameworks you can run fly launch and it will detect the framework and configure a container for you. For others you can pass it a Dockerfile which will be built and deployed. But you can also push your own images to a Docker registry and deploy them to Fly.
Today I figured out how to use Fly’s own registry to deploy an app.
Tagging images for the Fly registry#
Fly’s registry is called registry.fly.io. To use it, you need to tag your Docker images with a tag that begins with that string.
Every Fly app gets its own registry subdomain. You can create apps in a number of ways, but the easiest is to use the Fly CLI:
1flyctl apps create datasette-demoFly app names must be globally unique across all of Fly - you will get an error if the app name is already taken.
You can create an app with a random, freely available name using the --generate-name option:
1~ % flyctl apps create --generate-name2? Select Organization: Simon Willison (personal)3New app created: rough-dew-1296Now that you have an app name, you can tag your Docker image using:
1registry.fly.io/your-app-name:unique-tag-for-your-imageIf you are building an image using Docker on your machine, you can run this command in the same directory as your Dockerfile:
1docker build -t registry.fly.io/datasette-demo:datasette-demo-v0 .Pushing images to the registry#
In order to push your image to Fly, you will first need to authenticate.
The flyctl auth docker command will do this for you:
1~ % flyctl auth docker2Authentication successful. You can now tag and push images to registry.fly.io/{your-app}This works by hooking into Docker’s own authentication mechanism. You can see what it has done by looking at your ~/.docker/config.json file. Mine looks like this:
1{2 "auths": {3 "registry.fly.io": {4 "auth": "... secret token here ..."5 }6 ,7 "experimental": "disabled",8 "stackOrchestrator": "swarm"9}Now you can push your image to the registry like this:
1docker push registry.fly.io/datasette-demo:datasette-demo-v0Deploying an image#
Now that your image is pushed, you can deploy an instance of it like this:
1flyctl deploy --app datasette-demo \2 --image registry.fly.io/datasette-demo:datasette-demo-v0A few seconds later your app will be running at:
1https://name-of-your-app.fly.dev/