Simple hello world machine run example?

Hi, I’m just trying to kick the tyres with machines. And I cannot seem to get a simple job / script to show stdout in the logs, which makes me wonder if I’m even running it.

When I had a simple node -p 'console.log('hi')' it looked like the machine started → stopped fine but I never saw any stdout in the logs.

I tried a simple Dockerfile

FROM debian:wheezy

ENTRYPOINT ["/bin/sh", "-c"]

And then I try machine run:

fly machine run <image> --id <machine> -a <app> 'ls -la /'

And I just get:

Waiting on firecracker VM...

I know I am doing something very obviously wrong, but please help :dizzy_face:

My app has an empty services block, because it is just meant to be a job (e.g. download some files and zip them up, put them on a bucket). Would that affect health checks or something?

Thanks!

Oh and here is a much better reproducible example:

fly machine run debian:wheezy 'ls /'

There’s a known bug where flyctl might get stuck showing Waiting on firecracker VM, but it might’ve already started.

Does fly machine list -a <app> show a running machine for the ID printed when running it?

You can also fly machine run --id <machine> -a <app> . ls -la / and that will build your current directory’s Dockerfile.

It’s also possible this command exits so quickly it might’ve stopped already.

Can you check fly logs -a <app> to see if it logged the ls -la / result?

1 Like

I wish I knew that, that is fantastic!

Ok so machine list shows stopped - which is great. And when I go check the logs in the dash I can see the ls worked. So somewhere between my original command and that simple example is the issue, I’ll go bisect…

1 Like

Ok got this working, I used the curl API before so I must have done something weird, but here is a simple reduced working example for anyone else who needs it:

Dockerfile:

FROM node:18-alpine

# Create app directory
WORKDIR /usr/src/app

COPY src ./src

CMD [ "node", "src/index.js" ]

src/index.js:

console.log('hello world')

Then create/run the machine:

fly machine run .

Follow the prompts, create an app, check your logs:

hello world

Thanks again @jerome

3 Likes