Skip to content

Instantly share code, notes, and snippets.

@jpcaparas
Last active June 7, 2023 17:13
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save jpcaparas/95d6f81e70e7490713e60b2a484c32a4 to your computer and use it in GitHub Desktop.
Save jpcaparas/95d6f81e70e7490713e60b2a484c32a4 to your computer and use it in GitHub Desktop.
Limit docker CPU and memory resource usage
systemctl daemon-reload
systemctl restart docker
# /etc/docker/daemon.json
{
"cgroup-parent": "limit-docker-resource.slice"
}
# /etc/systemd/system/limit-docker-resource.slice
[Unit]
Description=Throttle CPU usage to 70% and memory usage to 8GB for docker-spawned processes
Before=slices.target
[Slice]
CPUQuota=70%
MemoryAccounting=true
MemoryLimit=8G
Inspired by: https://stackoverflow.com/questions/46408673/docker-17-06-ce-default-container-memory-limit-on-shared-host-resources/46557336#46557336
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment