# 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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.trentbauer.com/guides/other-guides/docker-compose/cpu-and-ram-limit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
