3030 dockerCmd * cobra.Command
3131 buildxCmd * cobra.Command
3232 buildxBuildCmd * cobra.Command
33+ buildxStopCmd * cobra.Command
3334)
3435
3536//nolint:errcheck
@@ -54,43 +55,52 @@ func init() {
5455 Short : "Start a build" ,
5556 Run : func (cmd * cobra.Command , args []string ) {},
5657 }
58+ buildxStopCmd = & cobra.Command {
59+ Use : "stop [NAME]" ,
60+ Short : "Stop builder instance" ,
61+ Run : func (cmd * cobra.Command , args []string ) {},
62+ }
63+
64+ buildxPFlags := buildxCmd .PersistentFlags ()
65+ buildxPFlags .String ("builder" , os .Getenv ("BUILDX_BUILDER" ), "Override the configured builder instance" )
5766
58- flags := buildxBuildCmd .Flags ()
59- flags .Bool ("push" , false , "Shorthand for --output=type=registry" )
60- flags .Bool ("load" , false , "Shorthand for --output=type=docker" )
61- flags .StringArrayP ("tag" , "t" , []string {}, "Name and optionally a tag in the 'name:tag' format" )
62- flags .SetAnnotation ("tag" , "docs.external.url" , []string {"https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t" })
63- flags .StringArray ("build-arg" , []string {}, "Set build-time variables" )
64- flags .SetAnnotation ("build-arg" , "docs.external.url" , []string {"https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg" })
65- flags .StringP ("file" , "f" , "" , "Name of the Dockerfile (Default is 'PATH/Dockerfile')" )
66- flags .SetAnnotation ("file" , "docs.external.url" , []string {"https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f" })
67- flags .StringArray ("label" , []string {}, "Set metadata for an image" )
68- flags .StringArray ("cache-from" , []string {}, "External cache sources (eg. user/app:cache, type=local,src=path/to/dir)" )
69- flags .StringArray ("cache-to" , []string {}, "Cache export destinations (eg. user/app:cache, type=local,dest=path/to/dir)" )
70- flags .String ("target" , "" , "Set the target build stage to build." )
71- flags .SetAnnotation ("target" , "docs.external.url" , []string {"https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target" })
72- flags .StringSlice ("allow" , []string {}, "Allow extra privileged entitlement, e.g. network.host, security.insecure" )
73- flags .StringArray ("platform" , []string {}, "Set target platform for build" )
74- flags .StringArray ("secret" , []string {}, "Secret file to expose to the build: id=mysecret,src=/local/secret" )
75- flags .StringArray ("ssh" , []string {}, "SSH agent socket or keys to expose to the build (format: `default|<id>[=<socket>|<key>[,<key>]]`)" )
76- flags .StringArrayP ("output" , "o" , []string {}, "Output destination (format: type=local,dest=path)" )
67+ buildxBuildFlags := buildxBuildCmd .Flags ()
68+ buildxBuildFlags .Bool ("push" , false , "Shorthand for --output=type=registry" )
69+ buildxBuildFlags .Bool ("load" , false , "Shorthand for --output=type=docker" )
70+ buildxBuildFlags .StringArrayP ("tag" , "t" , []string {}, "Name and optionally a tag in the 'name:tag' format" )
71+ buildxBuildFlags .SetAnnotation ("tag" , AnnotationExternalUrl , []string {"https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t" })
72+ buildxBuildFlags .StringArray ("build-arg" , []string {}, "Set build-time variables" )
73+ buildxBuildFlags .SetAnnotation ("build-arg" , AnnotationExternalUrl , []string {"https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg" })
74+ buildxBuildFlags .StringP ("file" , "f" , "" , "Name of the Dockerfile (Default is 'PATH/Dockerfile')" )
75+ buildxBuildFlags .SetAnnotation ("file" , AnnotationExternalUrl , []string {"https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f" })
76+ buildxBuildFlags .StringArray ("label" , []string {}, "Set metadata for an image" )
77+ buildxBuildFlags .StringArray ("cache-from" , []string {}, "External cache sources (eg. user/app:cache, type=local,src=path/to/dir)" )
78+ buildxBuildFlags .StringArray ("cache-to" , []string {}, "Cache export destinations (eg. user/app:cache, type=local,dest=path/to/dir)" )
79+ buildxBuildFlags .String ("target" , "" , "Set the target build stage to build." )
80+ buildxBuildFlags .SetAnnotation ("target" , AnnotationExternalUrl , []string {"https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target" })
81+ buildxBuildFlags .StringSlice ("allow" , []string {}, "Allow extra privileged entitlement, e.g. network.host, security.insecure" )
82+ buildxBuildFlags .StringArray ("platform" , []string {}, "Set target platform for build" )
83+ buildxBuildFlags .StringArray ("secret" , []string {}, "Secret file to expose to the build: id=mysecret,src=/local/secret" )
84+ buildxBuildFlags .StringArray ("ssh" , []string {}, "SSH agent socket or keys to expose to the build (format: `default|<id>[=<socket>|<key>[,<key>]]`)" )
85+ buildxBuildFlags .StringArrayP ("output" , "o" , []string {}, "Output destination (format: type=local,dest=path)" )
7786 // not implemented
78- flags .String ("network" , "default" , "Set the networking mode for the RUN instructions during build" )
79- flags .StringSlice ("add-host" , []string {}, "Add a custom host-to-IP mapping (host:ip)" )
80- flags .SetAnnotation ("add-host" , "docs.external.url" , []string {"https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host" })
81- flags .String ("iidfile" , "" , "Write the image ID to the file" )
87+ buildxBuildFlags .String ("network" , "default" , "Set the networking mode for the RUN instructions during build" )
88+ buildxBuildFlags .StringSlice ("add-host" , []string {}, "Add a custom host-to-IP mapping (host:ip)" )
89+ buildxBuildFlags .SetAnnotation ("add-host" , AnnotationExternalUrl , []string {"https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host" })
90+ buildxBuildFlags .String ("iidfile" , "" , "Write the image ID to the file" )
8291 // hidden flags
83- flags .BoolP ("quiet" , "q" , false , "Suppress the build output and print image ID on success" )
84- flags .MarkHidden ("quiet" )
85- flags .Bool ("squash" , false , "Squash newly built layers into a single new layer" )
86- flags .MarkHidden ("squash" )
87- flags .String ("ulimit" , "" , "Ulimit options" )
88- flags .MarkHidden ("ulimit" )
89- flags .StringSlice ("security-opt" , []string {}, "Security options" )
90- flags .MarkHidden ("security-opt" )
91- flags .Bool ("compress" , false , "Compress the build context using gzip" )
92+ buildxBuildFlags .BoolP ("quiet" , "q" , false , "Suppress the build output and print image ID on success" )
93+ buildxBuildFlags .MarkHidden ("quiet" )
94+ buildxBuildFlags .Bool ("squash" , false , "Squash newly built layers into a single new layer" )
95+ buildxBuildFlags .MarkHidden ("squash" )
96+ buildxBuildFlags .String ("ulimit" , "" , "Ulimit options" )
97+ buildxBuildFlags .MarkHidden ("ulimit" )
98+ buildxBuildFlags .StringSlice ("security-opt" , []string {}, "Security options" )
99+ buildxBuildFlags .MarkHidden ("security-opt" )
100+ buildxBuildFlags .Bool ("compress" , false , "Compress the build context using gzip" )
92101
93102 buildxCmd .AddCommand (buildxBuildCmd )
103+ buildxCmd .AddCommand (buildxStopCmd )
94104 dockerCmd .AddCommand (buildxCmd )
95105}
96106
@@ -108,7 +118,7 @@ func TestGenAllTree(t *testing.T) {
108118 require .NoError (t , err )
109119 require .NoError (t , c .GenAllTree ())
110120
111- for _ , tt := range []string {"buildx.md" , "buildx_build.md" , "docker_buildx.yaml" , "docker_buildx_build.yaml" } {
121+ for _ , tt := range []string {"buildx.md" , "buildx_build.md" , "buildx_stop.md" , " docker_buildx.yaml" , "docker_buildx_build.yaml" , "docker_buildx_stop .yaml" } {
112122 tt := tt
113123 t .Run (tt , func (t * testing.T ) {
114124 fres := filepath .Join (tmpdir , tt )
0 commit comments