Skip to content

Commit b284da3

Browse files
committed
docs: update BUILDING and README
Signed-off-by: Jess Valarezo <[email protected]>
1 parent b77fa49 commit b284da3

2 files changed

Lines changed: 68 additions & 59 deletions

File tree

BUILDING.md

Lines changed: 66 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,49 @@
33
This guide is useful if you intend to contribute on containerd. Thanks for your
44
effort. Every contribution is very appreciated.
55

6+
This doc includes:
7+
* [Build requirements](#build-requirements)
8+
* [Build the development environment](#build-the-development-environment)
9+
* [Build containerd](#build-containerd)
10+
* [Via docker container](#via-docker-container)
11+
* [Testing](#testing-containerd)
12+
13+
## Build requirements
14+
15+
To build the `containerd` daemon, and the `ctr` simple test client, the following build system dependencies are required:
16+
17+
* Go 1.9.x or above
18+
* Protoc 3.x compiler and headers (download at the [Google protobuf releases page](https://github.com/google/protobuf/releases))
19+
* Btrfs headers and libraries for your distribution. Note that building the btrfs driver can be disabled via the build tag `no_btrfs`, removing this dependency.
20+
621
## Build the development environment
722

8-
In first you need to setup your Go development environment. You can follow this
23+
First you need to setup your Go development environment. You can follow this
924
guideline [How to write go code](https://golang.org/doc/code.html) and at the
1025
end you need to have `GOPATH` and `GOROOT` set in your environment.
1126

12-
Current containerd requires Go 1.9.x or above.
13-
1427
At this point you can use `go` to checkout `containerd` in your `GOPATH`:
1528

1629
```sh
1730
go get github.com/containerd/containerd
1831
```
1932

33+
For proper results, install the `protoc` release into `/usr/local` on your build system. For example, the following commands will download and install the 3.5.0 release for a 64-bit Linux host:
34+
35+
```
36+
$ wget -c https://github.com/google/protobuf/releases/download/v3.5.0/protoc-3.5.0-linux-x86_64.zip
37+
$ sudo unzip protoc-3.5.0-linux-x86_64.zip -d /usr/local
38+
```
39+
2040
`containerd` uses [Btrfs](https://en.wikipedia.org/wiki/Btrfs) it means that you
2141
need to satisfy this dependencies in your system:
2242

2343
* CentOS/Fedora: `yum install btrfs-progs-devel`
2444
* Debian/Ubuntu: `apt-get install btrfs-tools`
2545

26-
At this point you are ready to build `containerd` yourself.
46+
At this point you are ready to build `containerd` yourself!
2747

28-
## In your local environment
48+
## Build containerd
2949

3050
`containerd` uses `make` to create a repeatable build flow. It means that you
3151
can run:
@@ -34,35 +54,49 @@ can run:
3454
make
3555
```
3656

37-
This is going to build all the binaries provided by this project in the `./bin`
38-
directory.
57+
This is going to build all the project binaries in the `./bin/` directory.
3958

40-
You can move them in your global path with:
59+
You can move them in your global path, `/usr/local/bin` with:
4160

4261
```sudo
4362
sudo make install
4463
```
4564

65+
When making any changes to the gRPC API, you can use the installed `protoc`
66+
compiler to regenerate the API generated code packages with:
67+
68+
```sudo
69+
make generate
70+
```
71+
72+
> *Note*: A build tag is currently available to disable building the btrfs snapshot driver.
73+
> Adding `BUILDTAGS=no_btrfs` to your environment before calling the **binaries**
74+
> Makefile target will disable the btrfs driver within the containerd Go build.
75+
76+
Vendoring of external imports uses the [`vndr` tool](https://github.com/LK4D4/vndr) which uses a simple config file, `vendor.conf`, to provide the URL and version or hash details for each vendored import. After modifying `vendor.conf` run the `vndr` tool to update the `vendor/` directory contents. Combining the `vendor.conf` update with the changeset in `vendor/` after running `vndr` should become a single commit for a PR which relies on vendored updates.
77+
78+
Please refer to [RUNC.md](/RUNC.md) for the currently supported version of `runc` that is used by containerd.
79+
4680
### Static binaries
4781

4882
You can build static binaries by providing a few variables to `make`:
4983

5084
```sudo
51-
make EXTRA_FLAGS="-buildmode pie" \
85+
make EXTRA_FLAGS="-buildmode pie" \
5286
EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"' \
5387
BUILDTAGS="static_build"
5488
```
5589

56-
Note that
57-
- static build is discouraged
58-
- static containerd binary does not support plugins loading
90+
> *Note*:
91+
> - static build is discouraged
92+
> - static containerd binary does not support loading plugins
5993
60-
## Via Docker Container
94+
# Via Docker container
6195

62-
### Build containerd
96+
## Build containerd
6397

64-
You can build `containerd` via Docker container. You can build an image from
65-
this `Dockerfile`:
98+
You can build `containerd` via a Linux-based Docker container.
99+
You can build an image from this `Dockerfile`:
66100

67101
```
68102
FROM golang
@@ -71,34 +105,34 @@ RUN apt-get update && \
71105
apt-get install btrfs-tools
72106
```
73107

74-
Let's suppose that you built an image called `containerd/build` and you are into
75-
the containerd root directory you can run the following command:
108+
Let's suppose that you built an image called `containerd/build`. From the
109+
containerd source root directory you can run the following command:
76110

77111
```sh
78-
docker run -it --rm \
112+
docker run -it \
79113
-v ${PWD}:/go/src/github.com/containerd/containerd \
80114
-e GOPATH=/go \
81-
-w /go/src/github.com/containerd/containerd containerd/build make
115+
-w /go/src/github.com/containerd/containerd containerd/build sh
82116
```
83117

84-
At this point you can find your binaries in the `./bin` directory in your host.
85-
You can move the binaries in your `$PATH` with the command:
118+
This mounts `containerd` repository
119+
120+
You are now ready to [build](#build-containerd):
86121

87122
```sh
88-
sudo make install
123+
make && make install
89124
```
90125

91-
### Build runc and containerd
92-
93-
To have complete core container runtime, you will need both `containerd` and `runc`. It is possible to build both of these via Docker container.
126+
## Build containerd and runc
127+
To have complete core container runtime, you will both `containerd` and `runc`. It is possible to build both of these via Docker container.
94128

95129
You can use `go` to checkout `runc` in your `GOPATH`:
96130

97131
```sh
98132
go get github.com/opencontainers/runc
99133
```
100134

101-
We can build an image from this `Dockerfile`
135+
We can build an image from this `Dockerfile`:
102136

103137
```sh
104138
FROM golang
@@ -108,7 +142,7 @@ RUN apt-get update && \
108142

109143
```
110144

111-
In our Docker container we will use a specific `runc` build which includes [seccomp](https://en.wikipedia.org/wiki/seccomp) and [apparmor](https://en.wikipedia.org/wiki/AppArmor) support. Hence why our Dockerfile includes these dependencies: `libapparmor-dev` `libseccomp-dev`.
145+
In our Docker container we will use a specific `runc` build which includes [seccomp](https://en.wikipedia.org/wiki/seccomp) and [apparmor](https://en.wikipedia.org/wiki/AppArmor) support. Hence why our Dockerfile includes these dependencies: `libapparmor-dev` `libseccomp-dev`. Please refer to [RUNC.md](/RUNC.md) for the currently supported version of `runc` that is used by containerd.
112146

113147
Let's suppose you build an image called `containerd/build` from the above Dockerfile. You can run the following command:
114148

@@ -117,13 +151,13 @@ docker run -it --privileged \
117151
-v /var/lib/containerd \
118152
-v ${GOPATH}/src/github.com/opencontainers/runc:/go/src/github.com/opencontainers/runc \
119153
-v ${GOPATH}/src/github.com/containerd/containerd:/go/src/github.com/containerd/containerd \
120-
-e GOPATH=/go
154+
-e GOPATH=/go \
121155
-w /go/src/github.com/containerd/containerd containerd/build sh
122156
```
123157

124158
This mounts both `runc` and `containerd` repositories in our Docker container.
125159

126-
From within our Docker container let's build `containerd`
160+
From within our Docker container let's build `containerd`:
127161

128162
```sh
129163
cd /go/src/github.com/containerd/containerd
@@ -133,14 +167,14 @@ make && make install
133167
These binaries can be found in the `./bin` directory in your host.
134168
`make install` will move the binaries in your `$PATH`.
135169

136-
Next, let's build `runc`
170+
Next, let's build `runc`:
137171

138172
```sh
139173
cd /go/src/github.com/opencontainers/runc
140174
make BUILDTAGS='seccomp apparmor' && make install
141175
```
142176

143-
When working with `ctr`, the containerd CLI we just built, don't forget to start `containerd`!
177+
When working with `ctr`, the simple test client we just built, don't forget to start the daemon!
144178

145179
```sh
146180
containerd --config config.toml

README.md

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ If you are interested in trying out containerd see our example at [Getting Start
2727

2828
Runtime requirements for containerd are very minimal. Most interactions with
2929
the Linux and Windows container feature sets are handled via [runc](https://github.com/opencontainers/runc) and/or
30-
OS-specific libraries (e.g. [hcsshim](https://github.com/Microsoft/hcsshim) for Microsoft). The current required version of runc is always listed in [RUNC.md](/RUNC.md).
30+
OS-specific libraries (e.g. [hcsshim](https://github.com/Microsoft/hcsshim) for Microsoft). The current required version of `runc` is always listed in [RUNC.md](/RUNC.md).
3131

3232
There are specific features
3333
used by containerd core code and snapshotters that will require a minimum kernel
@@ -43,7 +43,7 @@ distribution.
4343
To use Linux checkpoint and restore features, you will need `criu` installed on
4444
your system. See more details in [Checkpoint and Restore](#checkpoint-and-restore).
4545

46-
Build requirements for developers are listed in the [Developer Quick-Start](#developer-quick-start) section.
46+
Build requirements for developers are listed in [BUILDING](BUILDING.md).
4747

4848
## Features
4949

@@ -183,31 +183,6 @@ defer task.Delete(context)
183183
err := task.Start(context)
184184
```
185185

186-
## Developer Quick Start
187-
188-
To build the daemon and `ctr` simple test client, the following build system dependencies are required:
189-
190-
* Go 1.9.x or above
191-
* Protoc 3.x compiler and headers (download at the [Google protobuf releases page](https://github.com/google/protobuf/releases))
192-
* Btrfs headers and libraries for your distribution. Note that building the btrfs driver can be disabled via build tag removing this dependency.
193-
194-
For proper results, install the `protoc` release into `/usr/local` on your build system. For example, the following commands will download and install the 3.5.0 release for a 64-bit Linux host:
195-
196-
```
197-
$ wget -c https://github.com/google/protobuf/releases/download/v3.5.0/protoc-3.5.0-linux-x86_64.zip
198-
$ sudo unzip protoc-3.5.0-linux-x86_64.zip -d /usr/local
199-
```
200-
201-
With the required dependencies installed, the `Makefile` target named **binaries** will compile the `ctr` and `containerd` binaries and place them in the `bin/` directory. Using `sudo make install` will place the binaries in `/usr/local/bin`. When making any changes to the gRPC API, `make generate` will use the installed `protoc` compiler to regenerate the API generated code packages.
202-
203-
> *Note*: A build tag is currently available to disable building the btrfs snapshot driver.
204-
> Adding `BUILDTAGS=no_btrfs` to your environment before calling the **binaries**
205-
> Makefile target will disable the btrfs driver within the containerd Go build.
206-
207-
Vendoring of external imports uses the [`vndr` tool](https://github.com/LK4D4/vndr) which uses a simple config file, `vendor.conf`, to provide the URL and version or hash details for each vendored import. After modifying `vendor.conf` run the `vndr` tool to update the `vendor/` directory contents. Combining the `vendor.conf` update with the changeset in `vendor/` after running `vndr` should become a single commit for a PR which relies on vendored updates.
208-
209-
Please refer to [RUNC.md](/RUNC.md) for the currently supported version of `runc` that is used by containerd.
210-
211186
### Releases and API Stability
212187

213188
Please see [RELEASES.md](RELEASES.md) for details on versioning and stability

0 commit comments

Comments
 (0)