@@ -245,12 +245,11 @@ docker build github.com/docker/buildx#d4f088e689b41353d74f1a0bfcd6d7c0b213aed2
245245docker build github.com/docker/buildx#d4f088e
246246```
247247
248- ### URL queries
248+ #### URL queries
249249
250- Starting with Buildx v0.28 and BuildKit v0.24, URL queries are also supported.
251- URL queries are more structured and recommended over [ URL fragments] ( #url-fragments ) .
250+ Starting with Buildx v0.28, BuildKit v0.24 and Dockerfile v1.18 , URL queries are
251+ also supported. URL queries are more structured and recommended over [ URL fragments] ( #url-fragments ) :
252252
253- For example,
254253``` console
255254$ docker buildx build ' https://github.com/user/myrepo.git?branch=container&subdir=docker'
256255```
@@ -266,13 +265,29 @@ $ docker buildx build 'https://github.com/user/myrepo.git?branch=container&subdi
266265| ` myrepo.git?tag=mytag&subdir=myfolder ` | ` refs/tags/mytag ` | ` /myfolder ` |
267266| ` myrepo.git?branch=mybranch&subdir=myfolder ` | ` refs/heads/mybranch ` | ` /myfolder ` |
268267
269- A commit hash can be specified as a ` commit ` or ` checksum ` query, along with ` tag ` , ` branch ` , or ` ref ` .
270- A hash does not need to be a full hash.
268+ A commit hash can be specified as a ` checksum ` (alias ` commit ` ) query, along
269+ ` tag ` , ` branch ` , or ` ref ` queries to verify that the reference resolves to the
270+ expected commit:
271271
272- ``` bash
273- docker buildx build ' https://github.com/moby/buildkit.git?tag=v0.21.1&checksum=66735c67'
272+ ``` console
273+ $ docker buildx build ' https://github.com/moby/buildkit.git?tag=v0.21.1&checksum=66735c67'
274+ ```
275+
276+ If it doesn't match, the build fails:
277+
278+ ``` console
279+ $ docker buildx build ' https://github.com/user/myrepo.git?tag=v0.1.0&commit=deadbeef'
280+ ...
281+ #3 [internal] load git source https://github.com/user/myrepo.git?tag=v0.1.0-rc1&commit=deadbeef
282+ #3 0.484 bb41e835b6c3523c7c45b248cf4b45e7f862bc42 refs/tags/v0.1.0
283+ #3 ERROR: expected checksum to match deadbeef, got bb41e835b6c3523c7c45b248cf4b45e7f862bc42
274284```
275285
286+ > [ !NOTE]
287+ >
288+ > Short commit hash is supported with ` checksum ` (alias ` commit ` ) query but for
289+ > ` ref ` , only the full hash of the commit is supported.
290+
276291#### Keep ` .git ` directory
277292
278293By default, BuildKit doesn't keep the ` .git ` directory when using Git contexts.
0 commit comments