diff --git a/eng/docker-tools/CHANGELOG.md b/eng/docker-tools/CHANGELOG.md index 76a9ec60c8..99dbceb697 100644 --- a/eng/docker-tools/CHANGELOG.md +++ b/eng/docker-tools/CHANGELOG.md @@ -4,6 +4,27 @@ All breaking changes and new features in `eng/docker-tools` will be documented i --- +## 2026-04-02: Extra Docker build options can be passed through ImageBuilder + +- Pull request: [#2063](https://github.com/dotnet/docker-tools/pull/2063) + +ImageBuilder's `build` command now accepts repeated `--build-option` arguments and forwards them directly to +`docker build`. This allows repos to pass options such as `--ulimit nofile=65536:65536` or `--network host` +through `imageBuilderBuildArgs`, in addition to standard Dockerfile `--build-arg` values. + +**How to use:** + +```yaml +customBuildInitSteps: +- powershell: | + $args = '--build-option "--ulimit nofile=65536:65536"' + echo "##vso[task.setvariable variable=imageBuilderBuildArgs]$args" +``` + +Repeat `--build-option` for multiple Docker arguments, and quote values that contain spaces. + +--- + ## 2026-03-25: Manifest list creation moved to Post_Build - Issue: [#2002](https://github.com/dotnet/docker-tools/issues/2002) diff --git a/eng/docker-tools/DEV-GUIDE.md b/eng/docker-tools/DEV-GUIDE.md index 8297a6e6da..f834566d86 100644 --- a/eng/docker-tools/DEV-GUIDE.md +++ b/eng/docker-tools/DEV-GUIDE.md @@ -370,7 +370,7 @@ To force a rebuild regardless of cache state, set the `noCache` parameter to `tr ### Pattern: Adding Build Arguments -Pass additional arguments to Docker builds via ImageBuilder: +Pass Dockerfile `ARG` values via ImageBuilder: ```yaml customBuildInitSteps: @@ -379,6 +379,15 @@ customBuildInitSteps: echo "##vso[task.setvariable variable=imageBuilderBuildArgs]$args" ``` +To pass raw options directly to `docker build`, use `--build-option`. Quote values that contain spaces: + +```yaml +customBuildInitSteps: +- powershell: | + $args = '--build-option "--ulimit nofile=65536:65536"' + echo "##vso[task.setvariable variable=imageBuilderBuildArgs]$args" +``` + ### Pattern: Re-running Stages with `stages` and `sourceBuildPipelineRunId` A powerful pattern is combining the `stages` variable with the `sourceBuildPipelineRunId` pipeline parameter to run specific stages using artifacts from a previous build. This is useful for: