How limit cpu of docker buildx build? #3332
|
When using docker buildx build to create an image, it can cause the computer's CPU to max out. Are there any ways to limit CPU usage during the build process? |
Replies: 3 comments
|
A few options depending on your driver: If you're using the docker update --cpus 4 buildx_buildkit_<builder-name>0You can also set [worker.oci]
max-parallelism = 4Then create the builder with: docker buildx create --config ./buildkitd.tomlIf you're using the default |
|
Hi — I think the key distinction is that Buildx does not throttle CPU per build by default: the work runs inside BuildKit's daemon (buildkitd), which uses all available cores unless the daemon's container or runtime is resource-constrained. First check what is actually running: docker buildx ls
docker buildx inspect
docker infoIf you use the Could you share the output of |
|
Resource limits can now be set for CPU and memory using the More info: https://docs.docker.com/reference/cli/docker/buildx/build/#resource |
Resource limits can now be set for CPU and memory using the
--resourceflag in build and theresourcekey in bake commands. This feature requires BuildKit v0.31.0+ and Dockerfile v1.25.0+.More info: https://docs.docker.com/reference/cli/docker/buildx/build/#resource