how can I reuse the fly registry image of one app, for a machine

Hi,

I can the image ref of one of my apps to deploy a totally different app. Somehow fly finds the image and uses it. But while create a machine with that ref, it says it can not find the image.

This works

fly deploy --app sample-02 --image registry.fly.io/sample-01:latest

But this doesn’t, with the error that it couldn’t find the image. How can I make this work using the machines API and images from other apps?

fly machine run registry.fly.io/sample-01:latest

Hi @pmbanugo

Have you tried using a specific image version instead of using the latest alias?

what do you mean by specific image version?

Latest was just a dummy image tag because by default flyctl adds a timestamp to the image tag. My point is that same image works with fly deploy but not with fly machine run or using the machine api

Just commenting to surface this again and avoid it getting closed. Hopefully I get an answer

Based on the command provided for machine run, I’m guessing the problem could be you also need to include the app flag.

Hi @JP_Phillips I run it in a directory with the fly.toml so it automatically picks the app from there. BUt ideally I want to do this from the Machines API and that doesn’t work either.

Does it work for you when you try it?

Do you know if you happen to be using an App scoped API token?

no. it’s scoped to my account. I created it from the dashboard. AFAIK token created from the dashboard are scoped to my account, and so can access every org I belong to.

when I run fly deploy --build-only, doesn’t it push the image to the registry?

Depending on when you generated the token, it could be scoped to all Orgs or only a specific Org. Can you provide the names of the Apps?

I think I’m now able to narrow it down to the fact that the --build-only flag doesn’t save the image in the registry. I have the following apps

  • cronatlas-nodejs-alpine
  • restless-resonance-7989

I did a fly deploy for cronatlas-nodejs-alpine app which resulted in a deployment that created machines with the following image. registry.fly.io/cronatlas-nodejs-alpine:deployment-01HMY71DG6ZDNHZ6J1BPSGHRH1

Then fly deploy --remote-only --dockerfile Dockerfile.alpine --app cronatlas-nodejs-alpine --build-only which resulted in a new image

image: registry.fly.io/cronatlas-nodejs-alpine:deployment-01HMY7Y7KWS90E94VYNN05AADM
image size: 140 MB

This command works because it’s using the image tag for the one that was generated when I deployed: fly machine run --org cron-atlas registry.fly.io/cronatlas-nodejs-alpine:deployment-01HMY71DG6ZDNHZ6J1BPSGHRH1 --app restless-resonance-7989 --rm

Thiis one doesn’t because it’s using the image generated from the deploy with a --build-only flag: fly machine run --org cron-atlas registry.fly.io/cronatlas-nodejs-alpine:deployment-01HMY7Y7KWS90E94VYNN05AADM --app restless-resonance-7989 --rm

It shows the error:

Searching for image 'registry.fly.io/cronatlas-nodejs-alpine:deployment-01HMY7Y7KWS90E94VYNN05AADM' remotely...
Error: Could not find image "registry.fly.io/cronatlas-nodejs-alpine:deployment-01HMY7Y7KWS90E94VYNN05AADM"

So fly deploy with --build-only flag doesn’t push to the registry.

Does that make sense now?

Yea, that makes sense. You need to include the --push flag when using fly deploy to build and push an image.

Ahh I didn’t realise that. Can we just have --build-only do that? I think it’s easier to reason about.

Otherwise, what’s the purpose of having --build-only without pushing?

I have definitely hit this before when doing a build and push but we don’t plan to change the behavior of the flags.

1 Like

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