Skip to content

Commit 919beb1

Browse files
authored
Merge pull request #10593 from jjmaestro/patch-1
docs: Update BUILDING.md
2 parents a922786 + 4356837 commit 919beb1

1 file changed

Lines changed: 51 additions & 40 deletions

File tree

BUILDING.md

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -150,46 +150,44 @@ make STATIC=1
150150
151151
# Via Docker container
152152

153-
The following instructions assume you are at the parent directory of containerd source directory.
153+
> [!NOTE]
154+
> The following instructions assume you are at the **parent** directory of containerd source directory.
154155
155156
## Build containerd in a container
156157

157-
You can build `containerd` via a Linux-based Docker container.
158-
You can build an image from this `Dockerfile`:
158+
You can build `containerd` via a Linux-based Docker container using the [Docker official `golang` image](https://hub.docker.com/_/golang/)
159159

160-
```dockerfile
161-
FROM golang
162-
```
163-
164-
Let's suppose that you built an image called `containerd/build`. From the
165-
containerd source root directory you can run the following command:
160+
From the **parent** directory of `containerd`'s cloned repo you can run the following command:
166161

167162
```sh
168163
docker run -it \
169-
-v ${PWD}/containerd:/go/src/github.com/containerd/containerd \
170-
-e GOPATH=/go \
171-
-w /go/src/github.com/containerd/containerd containerd/build sh
164+
-v ${PWD}/containerd:/src/containerd \
165+
-w /src/containerd golang
172166
```
173167

174-
This mounts `containerd` repository
175-
176-
You are now ready to [build](#build-containerd):
168+
This mounts the `containerd` repository inside the image at `/src/containerd` and, by default, runs a shell at that directory.
177169

178-
```sh
179-
make && make install
180-
```
170+
Now, you are now ready to follow the [build instructions](#build-containerd):
181171

182172
## Build containerd and runc in a container
183173

184174
To have complete core container runtime, you will need both `containerd` and `runc`. It is possible to build both of these via Docker container.
185175

186-
You can use `git` to checkout `runc`:
176+
You can clone `runc` in the same parent directory where you cloned `containerd` and you should clone [the latest stable version of `runc`](https://github.com/opencontainers/runc/releases), e.g. v1.1.13:
187177

188178
```sh
189-
git clone https://github.com/opencontainers/runc
179+
git clone --branch <RELEASE_TAG> https://github.com/opencontainers/runc
190180
```
191181

192-
We can build an image from this `Dockerfile`:
182+
In our Docker container we will build `runc` build, which includes
183+
[seccomp](https://en.wikipedia.org/wiki/seccomp), [SELinux](https://en.wikipedia.org/wiki/Security-Enhanced_Linux),
184+
and [AppArmor](https://en.wikipedia.org/wiki/AppArmor) support. Seccomp support
185+
in runc requires `libseccomp-dev` as a dependency (AppArmor and SELinux support
186+
do not require external libraries at build time). Refer to [RUNC.md](docs/RUNC.md)
187+
in the docs directory to for details about building runc, and to learn about
188+
supported versions of `runc` as used by containerd.
189+
190+
Since we need [`libseccomp-dev`](https://packages.debian.org/stable/libseccomp-dev) installed as a dependency, we will need a custom Docker image derived from the official `golang` image. You can use the following `Dockerfile` to build your custom image:
193191

194192
```sh
195193
FROM golang
@@ -198,44 +196,57 @@ RUN apt-get update && \
198196
apt-get install -y libseccomp-dev
199197
```
200198

201-
In our Docker container we will build `runc` build, which includes
202-
[seccomp](https://en.wikipedia.org/wiki/seccomp), [SELinux](https://en.wikipedia.org/wiki/Security-Enhanced_Linux),
203-
and [AppArmor](https://en.wikipedia.org/wiki/AppArmor) support. Seccomp support
204-
in runc requires `libseccomp-dev` as a dependency (AppArmor and SELinux support
205-
do not require external libraries at build time). Refer to [RUNC.md](docs/RUNC.md)
206-
in the docs directory to for details about building runc, and to learn about
207-
supported versions of `runc` as used by containerd.
199+
Let's suppose you've built an image named `containerd/build` from the above `Dockerfile`.
208200

209-
Let's suppose you build an image called `containerd/build` from the above Dockerfile. You can run the following command:
201+
You can run the following command:
210202

211203
```sh
212-
docker run -it --privileged \
213-
-v /var/lib/containerd \
214-
-v ${PWD}/runc:/go/src/github.com/opencontainers/runc \
215-
-v ${PWD}/containerd:/go/src/github.com/containerd/containerd \
216-
-e GOPATH=/go \
217-
-w /go/src/github.com/containerd/containerd containerd/build sh
204+
docker run -it \
205+
-v ${PWD}/containerd:/src/containerd \
206+
-v ${PWD}/runc:/src/runc \
207+
-w /src/containerd \
208+
containerd/build
218209
```
219210

220211
This mounts both `runc` and `containerd` repositories in our Docker container.
221212

222-
From within our Docker container let's build `containerd`:
213+
From within the Docker container, let's build `containerd`:
223214

224215
```sh
225-
cd /go/src/github.com/containerd/containerd
226216
make && make install
227217
```
228218

229-
These binaries can be found in the `./bin` directory in your host.
230-
`make install` will move the binaries in your `$PATH`.
219+
You can check the installed binaries with:
220+
221+
```sh
222+
$ which containerd
223+
/usr/local/bin/containerd
224+
225+
$ containerd --version
226+
containerd github.com/containerd/containerd/v2 v2.0.0-rc.3-195-gf5d5407c2 f5d5407c2ff12865653a9a132d5783196be82763
227+
```
231228

232229
Next, let's build `runc`:
233230

234231
```sh
235-
cd /go/src/github.com/opencontainers/runc
232+
cd /src/runc
236233
make && make install
237234
```
238235

236+
You can check the installed binaries with:
237+
238+
```sh
239+
$ which runc
240+
/usr/local/sbin/runc
241+
242+
$ runc --version
243+
runc version 1.1.13
244+
commit: v1.1.13-0-g58aa9203
245+
spec: 1.0.2-dev
246+
go: go1.23.0
247+
libseccomp: 2.5.4
248+
```
249+
239250
For further details about building runc, refer to [RUNC.md](docs/RUNC.md) in the
240251
docs directory.
241252

0 commit comments

Comments
 (0)