Swap memory

Hi. Is there a way to configure swap memory for a Fly app? Or is this something that should configured in the Docker image (I’m using alpine:3.13)? I just SSHed into my instance and it looks like there is no swap configured.

# free -m
              total        used        free      shared  buff/cache   available
Mem:            228          83          69          35          74         117
Swap:             0           0           0

Thanks :slight_smile:

1 Like

Hi, I’ve just confirmed a deploy based on alpine using this as the final line in my Dockerfile:

CMD if [[ ! -z "$SWAP" ]]; then fallocate -l $(($(stat -f -c "(%a*%s/10)*7" .))) _swapfile && mkswap _swapfile && swapon _swapfile && ls -hla; fi; free -m; /app/run

You then need to set SWAP="true" in your fly.toml to enable the swap partition. That flag is needed to allow the container to run correctly under your local docker server.

1 Like