# Swap memory

**URL:** <https://community.fly.io/t/swap-memory/2749>\
**Category:** General\
**Created:** [October 7, 2021, 10:03pm UTC](https://community.fly.io/t/swap-memory/2749 "2021-10-07T22:03:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![OldhamMade](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/oldhammade/32/40954_2.png) [@OldhamMade](https://community.fly.io/u/OldhamMade)\
**Post date:** [November 1, 2021, 6:19am UTC](https://community.fly.io/t/swap-memory/2749/2 "2021-11-01T06:19:08Z")

</div>

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

```auto
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.

---

_[View the full topic](https://community.fly.io/t/swap-memory/2749)._
