Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 45171da

Browse files
committed
Annotate flags that are not supported by Buildkit
Before this patch: ``` Usage: docker build [OPTIONS] PATH | URL | - Build an image from a Dockerfile Options: --add-host list Add a custom host-to-IP mapping (host:ip) --build-arg list Set build-time variables --cache-from strings Images to consider as cache sources --cgroup-parent string Optional parent cgroup for the container --cpu-period int Limit the CPU CFS (Completely Fair Scheduler) period --cpu-quota int Limit the CPU CFS (Completely Fair Scheduler) quota -c, --cpu-shares int CPU shares (relative weight) --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) --disable-content-trust Skip image verification (default true) -f, --file string Name of the Dockerfile (Default is 'PATH/Dockerfile') --force-rm Always remove intermediate containers --iidfile string Write the image ID to the file --isolation string Container isolation technology --label list Set metadata for an image -m, --memory bytes Memory limit --memory-swap bytes Swap limit equal to memory plus swap: '-1' to enable unlimited swap --network string Set the networking mode for the RUN instructions during build (default "default") --no-cache Do not use cache when building the image -o, --output stringArray Output destination (format: type=local,dest=path) --platform string Set platform if server is multi-platform capable --progress string Set type of progress output (auto, plain, tty). Use plain to show container output (default "auto") --pull Always attempt to pull a newer version of the image -q, --quiet Suppress the build output and print image ID on success --rm Remove intermediate containers after a successful build (default true) --secret stringArray Secret file to expose to the build (only if BuildKit enabled): id=mysecret,src=/local/secret --security-opt strings Security options --shm-size bytes Size of /dev/shm --squash Squash newly built layers into a single new layer --ssh stringArray SSH agent socket or keys to expose to the build (only if BuildKit enabled) (format: default|<id>[=<socket>|<key>[,<key>]]) -t, --tag list Name and optionally a tag in the 'name:tag' format --target string Set the target build stage to build. --ulimit ulimit Ulimit options (default []) ``` With this patch applied: ``` DOCKER_BUILDKIT=1 docker build --help Usage: docker build [OPTIONS] PATH | URL | - Build an image from a Dockerfile Options: --add-host list Add a custom host-to-IP mapping (host:ip) --build-arg list Set build-time variables --cache-from strings Images to consider as cache sources --disable-content-trust Skip image verification (default true) -f, --file string Name of the Dockerfile (Default is 'PATH/Dockerfile') --iidfile string Write the image ID to the file --isolation string Container isolation technology --label list Set metadata for an image --network string Set the networking mode for the RUN instructions during build (default "default") --no-cache Do not use cache when building the image -o, --output stringArray Output destination (format: type=local,dest=path) --platform string Set platform if server is multi-platform capable --progress string Set type of progress output (auto, plain, tty). Use plain to show container output (default "auto") --pull Always attempt to pull a newer version of the image -q, --quiet Suppress the build output and print image ID on success --secret stringArray Secret file to expose to the build (only if BuildKit enabled): id=mysecret,src=/local/secret --squash Squash newly built layers into a single new layer --ssh stringArray SSH agent socket or keys to expose to the build (only if BuildKit enabled) (format: default|<id>[=<socket>|<key>[,<key>]]) -t, --tag list Name and optionally a tag in the 'name:tag' format --target string Set the target build stage to build. ``` Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit 7eecbb96afe752e38d5acb911fa719c2e7656242) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 25d53feb657fb2012d4e75e30863ae0fdf88634d Component: cli
1 parent 3a0d01d commit 45171da

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • components/cli/cli/command/image

components/cli/cli/command/image/build.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,28 +120,40 @@ func NewBuildCommand(dockerCli command.Cli) *cobra.Command {
120120
flags.VarP(&options.tags, "tag", "t", "Name and optionally a tag in the 'name:tag' format")
121121
flags.Var(&options.buildArgs, "build-arg", "Set build-time variables")
122122
flags.Var(options.ulimits, "ulimit", "Ulimit options")
123+
flags.SetAnnotation("ulimit", "no-buildkit", nil)
123124
flags.StringVarP(&options.dockerfileName, "file", "f", "", "Name of the Dockerfile (Default is 'PATH/Dockerfile')")
124125
flags.VarP(&options.memory, "memory", "m", "Memory limit")
126+
flags.SetAnnotation("memory", "no-buildkit", nil)
125127
flags.Var(&options.memorySwap, "memory-swap", "Swap limit equal to memory plus swap: '-1' to enable unlimited swap")
128+
flags.SetAnnotation("memory-swap", "no-buildkit", nil)
126129
flags.Var(&options.shmSize, "shm-size", "Size of /dev/shm")
130+
flags.SetAnnotation("shm-size", "no-buildkit", nil)
127131
flags.Int64VarP(&options.cpuShares, "cpu-shares", "c", 0, "CPU shares (relative weight)")
132+
flags.SetAnnotation("cpu-shares", "no-buildkit", nil)
128133
flags.Int64Var(&options.cpuPeriod, "cpu-period", 0, "Limit the CPU CFS (Completely Fair Scheduler) period")
134+
flags.SetAnnotation("cpu-period", "no-buildkit", nil)
129135
flags.Int64Var(&options.cpuQuota, "cpu-quota", 0, "Limit the CPU CFS (Completely Fair Scheduler) quota")
136+
flags.SetAnnotation("cpu-quota", "no-buildkit", nil)
130137
flags.StringVar(&options.cpuSetCpus, "cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)")
138+
flags.SetAnnotation("cpuset-cpus", "no-buildkit", nil)
131139
flags.StringVar(&options.cpuSetMems, "cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)")
140+
flags.SetAnnotation("cpuset-mems", "no-buildkit", nil)
132141
flags.StringVar(&options.cgroupParent, "cgroup-parent", "", "Optional parent cgroup for the container")
142+
flags.SetAnnotation("cgroup-parent", "no-buildkit", nil)
133143
flags.StringVar(&options.isolation, "isolation", "", "Container isolation technology")
134144
flags.Var(&options.labels, "label", "Set metadata for an image")
135145
flags.BoolVar(&options.noCache, "no-cache", false, "Do not use cache when building the image")
136146
flags.BoolVar(&options.rm, "rm", true, "Remove intermediate containers after a successful build")
147+
flags.SetAnnotation("rm", "no-buildkit", nil)
137148
flags.BoolVar(&options.forceRm, "force-rm", false, "Always remove intermediate containers")
149+
flags.SetAnnotation("force-rm", "no-buildkit", nil)
138150
flags.BoolVarP(&options.quiet, "quiet", "q", false, "Suppress the build output and print image ID on success")
139151
flags.BoolVar(&options.pull, "pull", false, "Always attempt to pull a newer version of the image")
140152
flags.StringSliceVar(&options.cacheFrom, "cache-from", []string{}, "Images to consider as cache sources")
141153
flags.BoolVar(&options.compress, "compress", false, "Compress the build context using gzip")
142154
flags.SetAnnotation("compress", "no-buildkit", nil)
143-
144155
flags.StringSliceVar(&options.securityOpt, "security-opt", []string{}, "Security options")
156+
flags.SetAnnotation("security-opt", "no-buildkit", nil)
145157
flags.StringVar(&options.networkMode, "network", "default", "Set the networking mode for the RUN instructions during build")
146158
flags.SetAnnotation("network", "version", []string{"1.25"})
147159
flags.Var(&options.extraHosts, "add-host", "Add a custom host-to-IP mapping (host:ip)")

0 commit comments

Comments
 (0)