Skip to content

Commit 52cedd4

Browse files
committed
guides: Add podman instructions to buildkit guide
1 parent 61276be commit 52cedd4

File tree

1 file changed

+49
-16
lines changed

1 file changed

+49
-16
lines changed

content/guides/building-dockerfile-images-with-buildkit.mdx

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,72 @@
22
title: Building Dockerfile Images with Buildkit
33

44
description: |
5-
This guide shows how to install buildkit to allow you to build Dockerfile images with Unikraft.
5+
This guide shows how to install Buildkit for building Dockerfile images with
6+
Unikraft.
67
---
78

8-
Unikraft uses [BuildKit](https://docs.docker.com/build/buildkit/), along with [Dockerfiles](https://docs.docker.com/reference/dockerfile/), to construct the root filesystem used by applications.
9+
Unikraft uses [BuildKit][buildkit], along with [Dockerfiles][dockerfiles], to
10+
construct the root filesystem used by applications.
911

10-
You can install BuildKit by either running it natively via systemd or in a container.
11-
Please refer to [BuildKit's installation instructions](https://github.com/moby/buildkit) for more information.
12+
We can install BuildKit either by running it natively via `systemd` or inside a
13+
container. Please refer to [BuildKit's installation
14+
instructions][buildkit-installation] for more information. For convenience, we
15+
recommend running it inside a container.
1216

13-
To use BuildKit with Docker on your system, you first need to install Docker following the [official instructions](https://docs.docker.com/engine/install/).
14-
This can be either [Docker Engine](https://docs.docker.com/engine/) or [Docker Desktop](https://docs.docker.com/desktop/).
17+
We will also need a [container engine][container-engine] on our host. Popular
18+
choices include [Docker][docker], [podman], and [containerd]. Please follow
19+
their respective documentation to get them up and running. For the rest of this
20+
article, we will assume Docker to be the installed container engine.
1521

16-
After installing Docker, you can run BuildKit in a container via:
22+
After installing the container engine, we can go ahead and run BuildKit.
1723

1824
```bash
1925
docker run -d --name buildkitd --privileged moby/buildkit:latest
2026
```
2127

22-
Now instruct `kraft` to use the BuildKit instance from the `buildkitd` container by either setting the environmental variable:
28+
We can check if the container launched by doing:
2329

2430
```bash
25-
export KRAFTKIT_BUILDKIT_HOST=docker-container://buildkitd
31+
$ docker container ps | grep buildkitd
2632
```
2733

28-
Or edit KraftKit's configuration file at `~/.config/kraftkit/config.yaml` and set the `buildkit_host` attribute.
29-
30-
To check that it worked you can run the following command:
31-
3234
```bash
33-
docker container ps | grep buildkit
35+
b146031cd4db moby/buildkit:latest "buildkitd" About a minute ago Up About a minute buildkit
3436
```
3537

36-
You should see output similar to:
38+
Now, we instruct `kraft` to use the BuildKit instance we launched. We can do it
39+
in the following ways:
40+
41+
- `KRAFTKIT_BUILDKIT_HOST` environment variable:
42+
```bash
43+
export KRAFTKIT_BUILDKIT_HOST=docker-container://buildkitd
44+
```
45+
- KraftKit's configuration file (`~/.config/kraftkit/config.yaml`):
46+
```yaml
47+
buildkit_host: docker-container://buildkitd
48+
```
49+
- Passing the `--buildkit-host` CLI flag to `kraft`:
50+
```bash
51+
kraft --buildkit-host=docker-container://buildkitd <args>
52+
```
53+
54+
> A container's URI depends on its name and the container engine. For example, a
55+
> container managed by `podman` will have `podman-container://buildkitd` as its
56+
> URI.
57+
58+
Since we gave a name to our container, we can use the `start` and `stop`
59+
subcommands to spawn/stop our BuildKit instance on demand.
3760

3861
```bash
39-
b146031cd4db moby/buildkit:latest "buildkitd" About a minute ago Up About a minute buildkit
62+
docker stop buildkitd # Start the container
63+
docker start buildkitd # Stop the container
4064
```
65+
66+
[buildkit]: https://docs.docker.com/build/buildkit/
67+
[Dockerfiles]: https://docs.docker.com/reference/dockerfile/
68+
[buildkit-installation]: https://github.com/moby/buildkit
69+
[container-engine]:
70+
https://developers.redhat.com/blog/2018/02/22/container-terminology-practical-introduction#h.6yt1ex5wfo3l
71+
[docker]: https://www.docker.com/
72+
[podman]: https://docs.podman.io/en/latest/
73+
[containerd]: https://containerd.io/

0 commit comments

Comments
 (0)