From d8abb61bedc5c41a4f5dff9b14b517bf24cdabb3 Mon Sep 17 00:00:00 2001 From: Jess Valarezo Date: Thu, 17 Aug 2017 10:21:03 -0700 Subject: [PATCH] Update building doc for Docker for Mac users Signed-off-by: Jess Valarezo --- BUILDING.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ RUNC.md | 10 +++++++-- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index f217d1e62..adce76c4f 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -45,6 +45,8 @@ sudo make install ## Via Docker Container +### Build containerd + You can build `containerd` via Docker container. You can build an image from this `Dockerfile`: @@ -71,3 +73,61 @@ You can move the binaries in your `$PATH` with the command: ```sh sudo make install ``` + +### Build runc and containerd + +To have complete core container runtime, you will need both `containerd` and `runc`. It is possible to build both of these via Docker container. + +You can use `go` to checkout `runc` in your `GOPATH`: + +```sh +go get github.com/opencontainers/runc +``` + +We can build an image from this `Dockerfile` + +```sh +FROM golang + +RUN apt-get update && \ + apt-get install -y btrfs-tools libapparmor-dev libseccomp-dev + +``` + +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`. + +Let's suppose you build an image called `containerd/build` from the above Dockerfile. You can run the following command: + +```sh +docker run -it --privileged \ + -v /var/lib/containerd \ + -v ${GOPATH}/src/github.com/opencontainers/runc:/go/src/github.com/opencontainers/runc \ + -v ${GOPATH}/src/github.com/containerd/containerd:/go/src/github.com/containerd/containerd \ + -e GOPATH=/go + -w /go/src/github.com/containerd/containerd containerd/build sh +``` + +This mounts both `runc` and `containerd` repositories in our Docker container. + +From within our Docker container let's build `containerd` + +```sh +cd /go/src/github.com/containerd/containerd +make && make install +``` + +These binaries can be found in the `./bin` directory in your host. +`make install` will move the binaries in your `$PATH`. + +Next, let's build `runc` + +```sh +cd /go/src/github.com/opencontainers/runc +make BUILDTAGS='seccomp apparmor' && make install +``` + +When working with `ctr`, the containerd CLI we just built, don't forget to start `containerd`! + +```sh +containerd --config config.toml +``` diff --git a/RUNC.md b/RUNC.md index cb009a213..fc9864a68 100644 --- a/RUNC.md +++ b/RUNC.md @@ -1,11 +1,17 @@ -containerd is built with OCI support and with support for advanced features provided by `runc`. +containerd is built with OCI support and with support for advanced features provided by [runc](https://github.com/opencontainers/runc). -We depend on a specific runc version when dealing with advanced features. You should have a specific build for development. The current supported runc commit is: +We depend on a specific `runc` version when dealing with advanced features. You should have a specific runc build for development. The current supported runc commit is: RUNC_COMMIT = e775f0fba3ea329b8b766451c892c41a3d49594d +For more information on how to clone and build runc see the runc Building [documentation](https://github.com/opencontainers/runc#building). + +Note: before building you may need to install additional support, which will vary by platform. For example, you may need to install `libseccomp` and `libapparmor` e.g. `libseccomp-dev` and `libapparmor-dev` for Ubuntu. + ## building +From within your `opencontainers/runc` repository run: + ### apparmor ```bash