Deploy locally built image

Hi,
I have a locally built image that I would like fly to deploy, but when I configure fly.toml to reference that local image tag, it keeps trying to get the image from dockerhub, where it doesn’t exist. I know that fly can build an image locally and posh it when a Docker file is present. Is it possible for it to deploy an image I’ve built locally myself?
Thanks,
Leigh

it’s definitely possible.

here is my deploy script (for podman, so you’d just tweak for docker)

podman login -u x --password $(fly auth token)
podman build -t my_app .
podman push --format v2s2 my_app docker://registry.fly.io/my_app:latest
flyctl deploy -i registry.fly.io/my_app:latest
1 Like

The image needs to be accessible to our platform when deploying so you need to push to either registry.fly.io or docker hub then deploy the image reference, either with the --image flag @flyio3 mentioned or in the fly.toml file.

If you’re using docker you can run flyctl auth docker to configure your credentials then push with docker push registry.fly.io/app:whateva

2 Likes

Ahh, got it. Thanks, makes sense.

I hadn’t realized I needed to push the image myself. I was configuring the image in the fly.toml, assuming it would push the local image in the same way building a Dockerfile happens locally.

Thanks!

1 Like

Is it still the case that local docker images needs to be pushed to registry.fly.io before deploying?
I noticed that when do so, the deploy step is once again pushing the local image to fly (thus increasing the build time which I am trying to optimize).

Basically I am doing this:

docker build -t registry.fly.io/myapp
flyctl auth docker
docker push registry.fly.io/myapp:latest
flyctl deploy -i registry.fly.io/myapp:latest -a myapp

But in logs I see the following:

tep 3/4: Pushing docker images to Fly.io registry
2024-04-17 03:03:59 UTC	Authentication successful. You can now tag and push images to registry.fly.io/{your-app}
2024-04-17 03:03:59 UTC	The push refers to repository [registry.fly.io/<concealed by 1Password>-staging]
2024-04-17 03:03:59 UTC	4c58a9d16c45: Preparing
2024-04-17 03:03:59 UTC	ed5f66ce43c5: Preparing
2024-04-17 03:03:59 UTC	bf83ef464e6d: Preparing
2024-04-17 03:03:59 UTC	05783ac4ef3c: Preparing
2024-04-17 03:03:59 UTC	926b35a05f1d: Preparing
2024-04-17 03:03:59 UTC	d4fc045c9e3a: Preparing
2024-04-17 03:03:59 UTC	d4fc045c9e3a: Waiting
2024-04-17 03:04:00 UTC	bf83ef464e6d: Layer already exists
2024-04-17 03:04:00 UTC	926b35a05f1d: Layer already exists
2024-04-17 03:04:00 UTC	ed5f66ce43c5: Layer already exists
2024-04-17 03:04:01 UTC	05783ac4ef3c: Layer already exists
2024-04-17 03:04:01 UTC	d4fc045c9e3a: Layer already exists
2024-04-17 03:05:23 UTC	4c58a9d16c45: Pushed
2024-04-17 03:05:36 UTC	latest: digest: sha256:558f4e13bb66f2d33c089f4b139c7a7d7202376d7860a043245f8e86d054f0ce size: 1577
2024-04-17 03:05:36 UTC	Step 4/4: Pushing packages to Fly.io registry
2024-04-17 03:05:36 UTC	Uploading to Fly.io...
2024-04-17 03:05:36 UTC	==> Verifying app config
2024-04-17 03:05:36 UTC	Validating /var/lib/buildkite-agent/builds/kite-10/corner/falcon/fly.toml
2024-04-17 03:05:36 UTC	✓ Configuration is valid
2024-04-17 03:05:36 UTC	--> Verified app config
2024-04-17 03:05:36 UTC	==> Building image
2024-04-17 03:05:36 UTC	Searching for image 'registry.fly.io/<concealed by 1Password>-staging:latest' locally...
2024-04-17 03:05:36 UTC	image found: sha256:a52d5c1d09395f74430090778c09aae04389c3976b291b939b44c5dd2acbe51e
2024-04-17 03:05:36 UTC	==> Pushing image to fly
2024-04-17 03:05:36 UTC	The push refers to repository [registry.fly.io/<concealed by 1Password>-staging]
2024-04-17 03:05:36 UTC	4c58a9d16c45: Preparing
2024-04-17 03:05:36 UTC	ed5f66ce43c5: Preparing
2024-04-17 03:05:36 UTC	bf83ef464e6d: Preparing
2024-04-17 03:05:36 UTC	05783ac4ef3c: Preparing
2024-04-17 03:05:36 UTC	926b35a05f1d: Preparing
2024-04-17 03:05:36 UTC	d4fc045c9e3a: Preparing
2024-04-17 03:05:36 UTC	d4fc045c9e3a: Waiting
2024-04-17 03:05:37 UTC	ed5f66ce43c5: Layer already exists
2024-04-17 03:05:37 UTC	4c58a9d16c45: Layer already exists
2024-04-17 03:05:37 UTC	bf83ef464e6d: Layer already exists
2024-04-17 03:05:37 UTC	05783ac4ef3c: Layer already exists
2024-04-17 03:05:37 UTC	926b35a05f1d: Layer already exists
2024-04-17 03:05:38 UTC	d4fc045c9e3a: Layer already exists
2024-04-17 03:05:40 UTC	deployment-01HVN08NKRM9PYWJA6BF76P8CC: digest: sha256:558f4e13bb66f2d33c089f4b139c7a7d7202376d7860a043245f8e86d054f0ce size: 1577
2024-04-17 03:05:40 UTC	--> Pushing image done
2024-04-17 03:05:41 UTC	
2024-04-17 03:05:41 UTC	Watch your deployment at https://fly.io/apps/<concealed by 1Password>-staging/monitoring
2024-04-17 03:05:41 UTC	

Notice the line in the log that says “Searching for image ‘registry.fly.io/<concealed by 1Password>-staging:latest’ locally…image found”.

So is the docker push step unnecessary at this time?