RAM Limit in Docker Container

I have an app that’s run with a Dockerfile. The scale on fly.io is set to ‘dedicated-cpu-8x’ and memory is ‘16GB’. The process I’m running has high RAM demands, but after troubleshooting some issues it looks like the Docker instance is only given roughly 350MB of RAM.

Is there a way to allow the Docker process to use the full amount of RAM?

Off the bat, I’m not sure what would drive this behavior for your app. Posting your fly $app-name status and fly scale show might help us dig into this a bit more!

The Docker entrypoint is npm run start which runs PORT=8080 node src/server. That node process runs os.totalmem() which returns 231MB (109MB free).

one-off $ fly status
App
  Name     = firm-app-one-off          
  Owner    = personal                  
  Hostname = firm-app-one-off.fly.dev  

ID              STATE   REGION  IMAGE                                                   CREATED                 UPDATED              
e784921c4dde83  stopped ord     registry.fly.io/firm-app-one-off:deployment-1659548665  2022-07-13T14:55:16Z    2022-08-03T17:55:00Z    

one-off $ fly scale show
VM Resources for firm-app-one-off
        VM Size: dedicated-cpu-8x
      VM Memory: 16 GB
          Count: 
 Max Per Region: 

Ah, okay, this makes more sense now, thank you!

I think might be able to help you workaround this behavior --it’s a bit confusing currently. So fly scale doesn’t work on machines. Taking a look on our end, this machine seems like a 1x-shared-cpu with 256mb RAM.You’ll want to run fly machines update to resize to a larger (shared-only) instance with more memory.

Thanks @eli - yeah, that explains it. I updated the RAM via the api and via the flyctl command, but it gets reset why I deploy. Is there a way to make the change more permanent?

Glad to hear that you have a workaround, but I can definitely see how the deploy behavior could be annoying, although I’m not quite sure why deploy is working like that.

Another workaround that might help in the meantime: since 1x-shared-cpu is the default, you could try specifying what size you want while creating the machine.

Digging around a bit further, this does appear to be a bug in fly deploy for machines-- creating a new machine wouldn’t be a workaround, after all. But fly machines update can be used instead, as long as you specify the machine size each time with --cpus

Thank you for bringing this up-- we’re looking into how to fix it!

Thanks eli - I’ve tried a few different options & it looks like the only solution right now is to run this command (or the API equivalent) after each deploy goes live:

flyctl machine update "$FLY_MACHINE_ID" --cpus 4 --memory 4096
2 Likes