This guide is not intended for end-users. Instead, this guide provides instructions for any developers eager to try Clear Containers 3.0 and who want to build Clear Containers from the source code and are familiar with the process.
The recommended way to create a development environment is to first install the packaged versions of the Clear Containers components to create a working system:
The installation guide instructions will install all packaged components, plus docker, the hypervisor and the Clear Containers image and kernel.
- go 1.8.3
- gcc and associated C language build tooling
such as
make
,autoconf
andlibtool
which are required to buildcc-shim
Since the installation guide will have installed packaged versions of all required components, it is only necessary to install the source for the component(s) you wish to develop with.
IMPORTANT: Do not combine Clear Containers 2.x and Clear Containers 3.x on the same system.
Both projects ship cc-proxy
and cc-shim
which are not compatible with each other.
See the upgrading document for further details.
-
Define GOPATH
$ export GOPATH=$HOME/go
-
Create GOPATH Directory
$ mkdir -p $GOPATH
-
Get the code
$ go get -d github.com/clearcontainers/runtime $ go get -d github.com/clearcontainers/proxy $ git clone https://github.com/clearcontainers/shim $GOPATH/src/github.com/clearcontainers/shim $ go get -d github.com/clearcontainers/agent $ go get -d github.com/clearcontainers/tests $ go get -d github.com/clearcontainers/osbuilder
-
Proxy
$ cd $GOPATH/src/github.com/clearcontainers/proxy $ make $ sudo make install
-
Shim
$ cd $GOPATH/src/github.com/clearcontainers/shim $ ./autogen.sh $ make $ sudo make install
-
Runtime
$ cd $GOPATH/src/github.com/clearcontainers/runtime $ make build-cc-system $ sudo -E PATH=$PATH make install-cc-system
-
Agent
$ cd $GOPATH/src/github.com/clearcontainers/agent $ make
The agent is installed inside the root filesystem image used by the hypervisor, hence to test a new agent version it is necessary to create a custom rootfs image. The example below demonstrates how to do this using the osbuilder tooling.
$ cd $GOPATH/src/github.com/clearcontainers/osbuilder $ # Create a rootfs image $ sudo -E make rootfs USE_DOCKER=true $ # Overwrite the default cc-agent binary with a custom built version $ sudo cp $GOPATH/src/github.com/clearcontainers/agent/cc-agent ./workdir/rootfs/usr/bin/cc-agent $ # Generate a container.img file $ sudo -E make image USE_DOCKER=true $ # Install the custom image $ sudo install --owner root --group root --mode 0755 workdir/container.img /usr/share/clear-containers/ $ # Update the runtime configuration $ # (note that this is only an example using default paths). $ sudo sed -i.bak -e 's!^\(image = ".*"\)!# \1 \ image = "/usr/share/clear-containers/container.img"!g' \ /usr/share/defaults/clear-containers/configuration.toml
For more details on the runtime's build system, run:
$ make help