> For the complete documentation index, see [llms.txt](https://www.trentbauer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.trentbauer.com/guides/other-guides/docker-compose/cpu-and-ram-limit.md).

# CPU and RAM limit

You can limit CPU and RAM to a container by using the Deploy setting,

### Set Limit

The docker container cannot use MORE than the limit set

<pre class="language-yaml"><code class="lang-yaml"> services:
   container:
<strong>    deploy:
</strong><strong>      resources:
</strong><strong>        limits:
</strong><strong>          cpus: ${CPU_LIMIT:-1}
</strong><strong>          memory: ${MEM_LIMIT:-100M}
</strong></code></pre>

### Set Reservation

These resources are kept available for the container

<pre class="language-yaml"><code class="lang-yaml"> services:
   container:
<strong>    deploy:
</strong><strong>      resources:
</strong><strong>        reservations:
</strong><strong>          cpus: ${CPU_RES:-1}
</strong><strong>          memory: ${MEM_RES:-100M}
</strong></code></pre>

You can use reservations and limits together
