Skip to content

Commit 7433e00

Browse files
committed
docs: Add details and examples for managing Builder Instances
1 parent c2d69e8 commit 7433e00

1 file changed

Lines changed: 71 additions & 2 deletions

File tree

docs/examples.md

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ A newly spawned agent won't contain any of the docker caches for the first run w
271271

272272
```yaml
273273
steps:
274-
- label: ":docker Build an image"
274+
- label: ":docker: Build an image"
275275
plugins:
276276
- docker-compose#v5.4.1:
277277
build: app
@@ -295,7 +295,7 @@ The values you add in the `cache-from` will be mapped to the corresponding servi
295295

296296
```yaml
297297
steps:
298-
- label: ":docker Build an image"
298+
- label: ":docker: Build an image"
299299
plugins:
300300
- docker-compose#v5.4.1:
301301
build: app
@@ -312,3 +312,72 @@ steps:
312312
push:
313313
- app:myregistry:port/myrepo/myapp:latest
314314
```
315+
316+
### Create, Use and Remove Builder Instances
317+
318+
#### Create
319+
320+
Most Docker setups, unless configured, will use the `docker` Builder Driver by default. More details on it [here](https://docs.docker.com/build/builders/drivers/docker/).
321+
322+
The `docker` driver can handle most situations but for advance features with the Docker, different Builder Drivers are required and this requires a Builder Instance being created first, which can be done manually or with the Plugin. To create a Builder Instance using a chosen Driver, requires the `name`, `driver` and `create` parameters:
323+
324+
```yaml
325+
steps:
326+
- label: ":docker: Build an image"
327+
plugins:
328+
- docker-compose#v5.4.1:
329+
build: app
330+
push: app:index.docker.io/myorg/myrepo:my-branch
331+
cache-from:
332+
- "app:myregistry:port/myrepo/myapp:my-branch"
333+
- "app:myregistry:port/myrepo/myapp:latest"
334+
driver:
335+
name: container
336+
driver: docker-container
337+
create: true
338+
```
339+
340+
**If a Builder Instance with the same `name` already exists, it will not be recreated.**
341+
342+
#### Use
343+
344+
By default, Builder Instances specified by `name` or that are created with `create` are not used, and the default Builder Instance on the Agent will be used. To use a Builder Instance, requires the `name` and `use` parameters and the Builder Instance to exist:
345+
346+
```yaml
347+
steps:
348+
- label: ":docker: Build an image"
349+
plugins:
350+
- docker-compose#v5.4.1:
351+
build: app
352+
push: app:index.docker.io/myorg/myrepo:my-branch
353+
cache-from:
354+
- "app:myregistry:port/myrepo/myapp:my-branch"
355+
- "app:myregistry:port/myrepo/myapp:latest"
356+
driver:
357+
name: container
358+
use: true
359+
```
360+
361+
#### Remove
362+
363+
By default, Builder Instances specified by `name` or that are created with `create` are not removed after the Job finishs. To remove a Builder Instance, requires the `name` and `remove` parameters and the Builder Instance to exist:
364+
365+
```yaml
366+
steps:
367+
- label: ":docker: Build an image"
368+
plugins:
369+
- docker-compose#v5.4.1:
370+
build: app
371+
push: app:index.docker.io/myorg/myrepo:my-branch
372+
cache-from:
373+
- "app:myregistry:port/myrepo/myapp:my-branch"
374+
- "app:myregistry:port/myrepo/myapp:latest"
375+
driver:
376+
name: container
377+
remove: true
378+
```
379+
380+
**Removing a Builder Instance by default will remove the daemon running it and its state (which can be used for cache).**
381+
**To keep the daemon or state, use the `keep-daemon` or `keep-state` parameters.**
382+
**These parameter are only applicable with specific Drivers, for detail see [`docker buildx rm`](https://docs.docker.com/reference/cli/docker/buildx/rm/).**
383+

0 commit comments

Comments
 (0)