You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: BUILDING.md
+66-32Lines changed: 66 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,29 +3,49 @@
3
3
This guide is useful if you intend to contribute on containerd. Thanks for your
4
4
effort. Every contribution is very appreciated.
5
5
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
+
6
21
## Build the development environment
7
22
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
9
24
guideline [How to write go code](https://golang.org/doc/code.html) and at the
10
25
end you need to have `GOPATH` and `GOROOT` set in your environment.
11
26
12
-
Current containerd requires Go 1.9.x or above.
13
-
14
27
At this point you can use `go` to checkout `containerd` in your `GOPATH`:
15
28
16
29
```sh
17
30
go get github.com/containerd/containerd
18
31
```
19
32
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:
`containerd` uses [Btrfs](https://en.wikipedia.org/wiki/Btrfs) it means that you
21
41
need to satisfy this dependencies in your system:
22
42
23
43
* CentOS/Fedora: `yum install btrfs-progs-devel`
24
44
* Debian/Ubuntu: `apt-get install btrfs-tools`
25
45
26
-
At this point you are ready to build `containerd` yourself.
46
+
At this point you are ready to build `containerd` yourself!
27
47
28
-
## In your local environment
48
+
## Build containerd
29
49
30
50
`containerd` uses `make` to create a repeatable build flow. It means that you
31
51
can run:
@@ -34,35 +54,49 @@ can run:
34
54
make
35
55
```
36
56
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.
39
58
40
-
You can move them in your global path with:
59
+
You can move them in your global path, `/usr/local/bin` with:
41
60
42
61
```sudo
43
62
sudo make install
44
63
```
45
64
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
+
46
80
### Static binaries
47
81
48
82
You can build static binaries by providing a few variables to `make`:
49
83
50
84
```sudo
51
-
makeEXTRA_FLAGS="-buildmode pie" \
85
+
makeEXTRA_FLAGS="-buildmode pie" \
52
86
EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"' \
53
87
BUILDTAGS="static_build"
54
88
```
55
89
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
59
93
60
-
##Via Docker Container
94
+
# Via Docker container
61
95
62
-
###Build containerd
96
+
## Build containerd
63
97
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`:
66
100
67
101
```
68
102
FROM golang
@@ -71,34 +105,34 @@ RUN apt-get update && \
71
105
apt-get install btrfs-tools
72
106
```
73
107
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:
-w /go/src/github.com/containerd/containerd containerd/build make
115
+
-w /go/src/github.com/containerd/containerd containerd/build sh
82
116
```
83
117
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):
86
121
87
122
```sh
88
-
sudo make install
123
+
make && make install
89
124
```
90
125
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.
94
128
95
129
You can use `go` to checkout `runc` in your `GOPATH`:
96
130
97
131
```sh
98
132
go get github.com/opencontainers/runc
99
133
```
100
134
101
-
We can build an image from this `Dockerfile`
135
+
We can build an image from this `Dockerfile`:
102
136
103
137
```sh
104
138
FROM golang
@@ -108,7 +142,7 @@ RUN apt-get update && \
108
142
109
143
```
110
144
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.
112
146
113
147
Let's suppose you build an image called `containerd/build` from the above Dockerfile. You can run the following command:
114
148
@@ -117,13 +151,13 @@ docker run -it --privileged \
Copy file name to clipboardExpand all lines: README.md
+2-27Lines changed: 2 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ If you are interested in trying out containerd see our example at [Getting Start
27
27
28
28
Runtime requirements for containerd are very minimal. Most interactions with
29
29
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).
31
31
32
32
There are specific features
33
33
used by containerd core code and snapshotters that will require a minimum kernel
@@ -43,7 +43,7 @@ distribution.
43
43
To use Linux checkpoint and restore features, you will need `criu` installed on
44
44
your system. See more details in [Checkpoint and Restore](#checkpoint-and-restore).
45
45
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).
47
47
48
48
## Features
49
49
@@ -183,31 +183,6 @@ defer task.Delete(context)
183
183
err:= task.Start(context)
184
184
```
185
185
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:
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
-
211
186
### Releases and API Stability
212
187
213
188
Please see [RELEASES.md](RELEASES.md) for details on versioning and stability
0 commit comments