mirror of
https://github.com/Dokploy/website.git
synced 2026-06-15 20:25:25 +02:00
docs: enhance resource management section in advanced.mdx
- Expanded the documentation on managing memory and CPU resources for applications, including detailed explanations of memory and CPU limits and reservations. - Added user-friendly examples and formats for input values, ensuring clarity on how to set resource constraints. - Included important reminders regarding the relationship between memory and CPU reservations and limits. - Updated the file mount description to clarify its persistence across deployments.
This commit is contained in:
@@ -101,12 +101,131 @@ Modifying Swarm Settings requires careful consideration as incorrect configurati
|
||||
|
||||
## Resources
|
||||
|
||||
Manage the memory and CPU resources allocated to your applications or databases.
|
||||
Manage the memory and CPU resources allocated to your applications or databases. These settings help control resource consumption and ensure fair distribution across your containers.
|
||||
|
||||
- **Memory Reservation**: The minimum amount of memory guaranteed to the application.
|
||||
- **Memory Limit**: The maximum amount of memory the application can use.
|
||||
- **CPU Limit**: The maximum number of CPU units that the application can utilize.
|
||||
- **CPU Reservation**: The minimum number of CPU units reserved for the application.
|
||||
<Callout type="info">
|
||||
Remember to click **Redeploy** after modifying the resources to apply the changes.
|
||||
</Callout>
|
||||
|
||||
### Memory Resources
|
||||
|
||||
Docker API expects memory values in **bytes**. Dokploy provides a user-friendly interface that accepts values with units and converts them automatically.
|
||||
|
||||
#### Memory Limit
|
||||
|
||||
The maximum amount of memory the container can use. If the container tries to use more memory than this limit, it will be killed by the Docker daemon.
|
||||
|
||||
**Format**: Enter a number followed by the unit (B, KB, MB, GB)
|
||||
|
||||
**Docker API Value**: The value is converted to bytes internally
|
||||
- `1073741824` bytes = 1GB
|
||||
- `268435456` bytes = 256MB
|
||||
- `536870912` bytes = 512MB
|
||||
|
||||
**Examples**:
|
||||
- `256MB` → Limits container to 256 megabytes
|
||||
- `1GB` → Limits container to 1 gigabyte
|
||||
- `2GB` → Limits container to 2 gigabytes
|
||||
|
||||
#### Memory Reservation
|
||||
|
||||
The minimum amount of memory guaranteed to the container. Docker will try to ensure this amount is always available, but the container can use more if available.
|
||||
|
||||
**Format**: Enter a number followed by the unit (B, KB, MB, GB)
|
||||
|
||||
**Docker API Value**: The value is converted to bytes internally
|
||||
- `268435456` bytes = 256MB
|
||||
- `536870912` bytes = 512MB
|
||||
|
||||
**Examples**:
|
||||
- `128MB` → Reserves at least 128 megabytes
|
||||
- `256MB` → Reserves at least 256 megabytes
|
||||
- `512MB` → Reserves at least 512 megabytes
|
||||
|
||||
<Callout type="warn">
|
||||
Memory Reservation should always be **less than or equal to** Memory Limit. If you set a reservation higher than the limit, Docker will use the limit value.
|
||||
</Callout>
|
||||
|
||||
### CPU Resources
|
||||
|
||||
Docker API expects CPU values in **nanoseconds** (for periods) or as a decimal fraction of available CPU cores. Dokploy displays this in a user-friendly format.
|
||||
|
||||
#### CPU Limit
|
||||
|
||||
The maximum number of CPU cores the container can use. This is a hard limit enforced by the Docker daemon.
|
||||
|
||||
**Format**: Enter as a decimal number representing CPU cores
|
||||
- `2000000000` nanoseconds = 2 CPUs (2 full cores)
|
||||
- `1000000000` nanoseconds = 1 CPU (1 full core)
|
||||
- `500000000` nanoseconds = 0.5 CPU (half a core)
|
||||
|
||||
**Docker API Value**: Internally represented as `NanoCPUs`
|
||||
|
||||
**Examples**:
|
||||
- `1 CPU` → Limits to 1 full CPU core (1000000000 nanoseconds)
|
||||
- `2 CPUs` → Limits to 2 full CPU cores (2000000000 nanoseconds)
|
||||
- `0.5 CPU` → Limits to half a CPU core (500000000 nanoseconds)
|
||||
- `4 CPUs` → Limits to 4 full CPU cores (4000000000 nanoseconds)
|
||||
|
||||
#### CPU Reservation
|
||||
|
||||
The minimum number of CPU cores reserved for the container. Docker will try to ensure this amount is always available.
|
||||
|
||||
**Format**: Enter as a decimal number representing CPU cores
|
||||
- `1000000000` nanoseconds = 1 CPU
|
||||
- `500000000` nanoseconds = 0.5 CPU
|
||||
|
||||
**Docker API Value**: Internally represented as `NanoCPUs`
|
||||
|
||||
**Examples**:
|
||||
- `0.5 CPU` → Reserves half a CPU core (500000000 nanoseconds)
|
||||
- `1 CPU` → Reserves 1 full CPU core (1000000000 nanoseconds)
|
||||
- `0.25 CPU` → Reserves a quarter CPU core (250000000 nanoseconds)
|
||||
|
||||
<Callout type="warn">
|
||||
CPU Reservation should always be **less than or equal to** CPU Limit. Setting it too high may prevent the container from starting if resources aren't available.
|
||||
</Callout>
|
||||
|
||||
|
||||
|
||||
#### Docker API Reference
|
||||
|
||||
When Dokploy communicates with Docker API, these values are sent in the service specification:
|
||||
|
||||
```json
|
||||
{
|
||||
"TaskTemplate": {
|
||||
"Resources": {
|
||||
"Limits": {
|
||||
"NanoCPUs": 2000000000,
|
||||
"MemoryBytes": 1073741824
|
||||
},
|
||||
"Reservations": {
|
||||
"NanoCPUs": 1000000000,
|
||||
"MemoryBytes": 536870912
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This JSON represents:
|
||||
- **CPU Limit**: 2 CPUs (2000000000 nanoseconds)
|
||||
- **Memory Limit**: 1GB (1073741824 bytes)
|
||||
- **CPU Reservation**: 1 CPU (1000000000 nanoseconds)
|
||||
- **Memory Reservation**: 512MB (536870912 bytes)
|
||||
|
||||
#### Learn More
|
||||
|
||||
For detailed information about Docker API resource specifications and service creation, refer to the official Docker Engine API documentation:
|
||||
|
||||
[Docker Engine API - Service Create](https://docs.docker.com/reference/api/engine/version/v1.51/#tag/Service/operation/ServiceCreate)
|
||||
|
||||
This documentation includes:
|
||||
- Complete resource specification schema
|
||||
- Advanced configuration options
|
||||
- API request/response examples
|
||||
- Additional parameters and constraints
|
||||
|
||||
|
||||
### Volumes/Mounts
|
||||
@@ -127,7 +246,7 @@ Configure persistent storage for your application to ensure data remains intact
|
||||
2. **File Path**: The name of the file.
|
||||
3. **Mount Path**: Path in the container where the file is placed. **The path must also contain the filename.**
|
||||
|
||||
File mounts are a dokploy features, this create a file in a folder called `files` inside your project, so it recreates every single time you deploy your project.
|
||||
File mounts are a Dokploy feature. When you create a file mount, Dokploy stores the file in a folder called `files` inside your project directory. This file is created once when you set up the file mount and persists across deployments.
|
||||
|
||||
<ImageZoom src="/assets/file-mount-configuration.webp" width={800} height={630} className="rounded-lg"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user