Skip to content

Commit

Permalink
[CI] Allow Limit CPUs in Docker (apache#15668)
Browse files Browse the repository at this point in the history
This PR adds a new flag `--cpus` in `./docker/bash.sh`, which is passed
to docker command that allows limiting the number of CPU cores of a
docker container.

Related materials: https://docs.docker.com/config/containers/resource_constraints/#configure-the-default-cfs-scheduler
  • Loading branch information
junrushao authored Sep 6, 2023
1 parent d26fdcf commit ea388e5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions docker/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ set -euo pipefail
function show_usage() {
cat <<EOF
Usage: docker/bash.sh [-i|--interactive] [--net=host] [-t|--tty]
[--mount MOUNT_DIR] [--repo-mount-point REPO_MOUNT_POINT]
[--dry-run] [--name NAME]
<DOCKER_IMAGE_NAME> [--] [COMMAND]
[--cpus NUM_CPUS] [--mount MOUNT_DIR]
[--repo-mount-point REPO_MOUNT_POINT]
[--dry-run] [--name NAME]
<DOCKER_IMAGE_NAME> [--] [COMMAND]
-h, --help
Expand All @@ -54,6 +56,10 @@ Usage: docker/bash.sh [-i|--interactive] [--net=host] [-t|--tty]
Start the docker session with a pseudo terminal (tty).
--cpus NUM_CPUS
Limit the number of CPU cores to be used.
--net=host
Expose servers run into the container to the host, passing the
Expand Down Expand Up @@ -184,6 +190,11 @@ while (( $# )); do
eval $break_joined_flag
;;

--cpus)
DOCKER_FLAGS+=(--cpus "$2")
shift 2
;;

--net=host)
USE_NET_HOST=true
shift
Expand Down

0 comments on commit ea388e5

Please sign in to comment.