Using Machines how to create image?

Hey guys,

This might be a bit of a noob question but when using Machines one must provide an image. How do I obtain the URL to put there? I dont want to publicly share my image on DockerHub…


Create an app and push your image to the fly registry with the app name as image name.

To be clear im trying to follow the Terraform with Machines tutorial here: Getting started with Machines and Terraform · Fly Docs

So you are saying to get the image to use in Terraform I must first create an app? I was hoping I could simply do terraform init terraform apply and have it work…

The image defined there needs to be publicly available without authentication, or be pushed into’s Fly’s registry.

Terraform isn’t great at the part. Packer can do that!

Alternatively, Terraform has a “local exec” resource you can use to run arbitrary commands, which can let you push a docker image to Fly’s registry using fly auth docker followed by docker push…

There might be a better way I don’t know about!

Not a better way, but a way that I use:

# create fly app if non existent
flyctl apps create --name <app-name> --org <org-name> 

# also: --local-only instead of --remote-only
flyctl deploy --build-only --remote-only --dockerfile /path/to/dockerfile --push --image <img-label> -a <app-name>

# the image to use can be referenced with url:

see also, its dual: Pulling the Container - #3 by eli

I found this helpful when faced with the same issue of not wanted to make our image public. Tag it and then push it to the your apps private repo.

1 Like

This is exactly what I was looking for thanks!

This should be in the official docs :slight_smile:

1 Like

Recently a commit went in that now lets one build and run a machine with a single cmd (notice the . after m run and specify a path to the --dockerfile):

flyctl m run . --dockerfile </path/to/file> ...
1 Like