Skip to content

Commit cd947b6

Browse files
committed
build: document URL queries
BuildKit v0.24 introduces URL like `https://github.com/example/example.git?tag=v0.0.1&checksum=deadbeef` See moby/buildkit PR 6172 Signed-off-by: Akihiro Suda <[email protected]>
1 parent 3d174fd commit cd947b6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

content/manuals/build/concepts/context.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,40 @@ docker build github.com/docker/buildx#d4f088e689b41353d74f1a0bfcd6d7c0b213aed2
245245
docker build github.com/docker/buildx#d4f088e
246246
```
247247

248+
### URL queries
249+
<!-- WIP: BuildKit PR is merged (https://github.com/moby/buildkit/pull/6172),
250+
not supported in Buildx context yet -->
251+
252+
Starting with Buildx v0.28 and BuildKit v0.24, URL queries are also supported.
253+
URL queries are more structured and recommended over [URL fragments](#url-fragments).
254+
255+
For example,
256+
```console
257+
$ docker buildx build https://github.com/user/myrepo.git?branch=container&subdir=docker
258+
```
259+
260+
| Build Syntax Suffix | Commit Used | Build Context Used |
261+
| -------------------------------------------- | ----------------------------- | ------------------ |
262+
| `myrepo.git` | `refs/heads/<default branch>` | `/` |
263+
| `myrepo.git?tag=mytag` | `refs/tags/mytag` | `/` |
264+
| `myrepo.git?branch=mybranch` | `refs/heads/mybranch` | `/` |
265+
| `myrepo.git?ref=pull/42/head` | `refs/pull/42/head` | `/` |
266+
| `myrepo.git?subdir=myfolder` | `refs/heads/<default branch>` | `/myfolder` |
267+
| `myrepo.git?branch=master&subdir=myfolder` | `refs/heads/master` | `/myfolder` |
268+
| `myrepo.git?tag=mytag&subdir=myfolder` | `refs/tags/mytag` | `/myfolder` |
269+
| `myrepo.git?branch=mybranch&subdir=myfolder` | `refs/heads/mybranch` | `/myfolder` |
270+
271+
272+
A commit hash can be specified as a `commit` or `checksum` query.
273+
Unlike `ref` fragment, a `commit` query does not need to be a full commit hash.
274+
275+
```bash
276+
# ✅ The following works:
277+
docker buildx build https://github.com/docker/buildx.git?commit=d4f088e689b41353d74f1a0bfcd6d7c0b213aed2
278+
# ✅ Thie following works too:
279+
docker buildx build https://github.com/docker/buildx.git?commit=d4f088e
280+
```
281+
248282
#### Keep `.git` directory
249283

250284
By default, BuildKit doesn't keep the `.git` directory when using Git contexts.

0 commit comments

Comments
 (0)