add
This commit is contained in:
parent
e31cd7bf70
commit
bced53410d
@ -0,0 +1,38 @@
|
|||||||
|
# Docker Compose: 限制容器的资源使用
|
||||||
|
|
||||||
|
## 修改 docker-compose.yml
|
||||||
|
|
||||||
|
限制资源配置字段为 `deploy.resources.limits`,以下是示例 docker-compose.yml
|
||||||
|
|
||||||
|
``` title="docker-compose.yml"
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
umami:
|
||||||
|
image: docker.umami.dev/umami-software/umami:mysql-latest
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: '0.50'
|
||||||
|
memory: 500M
|
||||||
|
reservations:
|
||||||
|
cpus: '0.25'
|
||||||
|
memory: 200M
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: mysql://umami:xxx@127.0.0.1:3306/umami
|
||||||
|
DATABASE_TYPE: mysql
|
||||||
|
HASH_SALT: replace-me-with-a-random-string
|
||||||
|
restart: always
|
||||||
|
network_mode: "host"
|
||||||
|
```
|
||||||
|
|
||||||
|
在以上示例中,Umami 容器的 CPU 使用限制在 25%-50%,内存使用限制在 200MB-500MB。
|
||||||
|
|
||||||
|
## 修改 docker compose 启动命令
|
||||||
|
|
||||||
|
传入参数 `--compatibility` 表示以兼容模式来运行
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose --compatibility up -d
|
||||||
|
```
|
@ -79,9 +79,10 @@ nav:
|
|||||||
- tech/index.md
|
- tech/index.md
|
||||||
- "Mi 6 (sagit)": tech/Mi6(sagit).md
|
- "Mi 6 (sagit)": tech/Mi6(sagit).md
|
||||||
- "极1S (HC5661)": tech/HC5661.md
|
- "极1S (HC5661)": tech/HC5661.md
|
||||||
- "Redmi 4X (santoni)": tech/Redmi4X(santoni).md
|
|
||||||
- "Git: 覆盖本地修改": tech/Git-overwriting-local-changes.md
|
- "Git: 覆盖本地修改": tech/Git-overwriting-local-changes.md
|
||||||
|
- "Redmi 4X (santoni)": tech/Redmi4X(santoni).md
|
||||||
- "手把手教你备份和还原 Docker 卷": tech/Backup-and-Restore-of-Docker-Volumes-A-Step-by-Step-Guide.md
|
- "手把手教你备份和还原 Docker 卷": tech/Backup-and-Restore-of-Docker-Volumes-A-Step-by-Step-Guide.md
|
||||||
|
- "Docker Compose: 限制容器的资源使用": tech/Docker-Compose-Limiting-container-resource-usage.md
|
||||||
- "创建和管理 Linux 服务器用于身份验证的 SSH 密钥": tech/Creating-and-Managing-SSH-Keys-for-Authentication-on-Linux-Servers.md
|
- "创建和管理 Linux 服务器用于身份验证的 SSH 密钥": tech/Creating-and-Managing-SSH-Keys-for-Authentication-on-Linux-Servers.md
|
||||||
- "MkDocs 参考": examples/index.md
|
- "MkDocs 参考": examples/index.md
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user