Dockerコンテナのメモリ使用量を制限する
- Docker Engine 24.0
- Docker Compose 2.21
Docker
# 100 MBsudo docker update --memory "100m" "$CONTAINER_ID"# 1 GBsudo docker update --memory "1g" "$CONTAINER_ID"# 制限を解除sudo docker update --memory "0" "$CONTAINER_ID"
Docker Compose
app:image: hello-worlddeploy:resources:limits:memory: '1g'