Schlagwort-Archive: docker

Opencontainer runc on Ubuntu 14.04

Prerequesits:

running golang with golang path set and golang-bin path set … okay refresh here, if not yet done

## create a working directory

mkdir -pv ~/gocode/github.com/

vim ~/.profile

## add this two lines

export GOPATH=/home/tbade/gocode

export PATH=$PATH:$GOPATH/bin

## check out also FIX 2 down below (to install latest Golang)

The normal way of using runC …

# create a ‚github.com/opencontainers‘ in your GOPATH
cd github.com/opencontainers
git clone https://github.com/opencontainers/runc
cd runc
make
sudo make install

I had some Issues with Linux Mint17 and Ubuntu 14.04, while building runc … and a small workaround fo fix it:
1. ISSUE

tbade@torbuntu:~/gocode/github.com/opencontainers/runc$ make
go build -o runc .
checkpoint.go:11:2: cannot find package „github.com/opencontainers/runc/libcontainer“ in any of:
/usr/lib/go/src/pkg/github.com/opencontainers/runc/libcontainer (from $GOROOT)
/home/tbade/gocode/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer (from $GOPATH)
/home/tbade/gocode/src/github.com/opencontainers/runc/libcontainer
spec_linux.go:13:2: cannot find package „github.com/opencontainers/runc/libcontainer/cgroups“ in any of:
/usr/lib/go/src/pkg/github.com/opencontainers/runc/libcontainer/cgroups (from $GOROOT)
/home/tbade/gocode/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/cgroups (from $GOPATH)
/home/tbade/gocode/src/github.com/opencontainers/runc/libcontainer/cgroups
restore.go:13:2: cannot find package „github.com/opencontainers/runc/libcontainer/configs“ in any of:
/usr/lib/go/src/pkg/github.com/opencontainers/runc/libcontainer/configs (from $GOROOT)
/home/tbade/gocode/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/configs (from $GOPATH)
/home/tbade/gocode/src/github.com/opencontainers/runc/libcontainer/configs
spec_linux.go:15:2: cannot find package „github.com/opencontainers/runc/libcontainer/devices“ in any of:
/usr/lib/go/src/pkg/github.com/opencontainers/runc/libcontainer/devices (from $GOROOT)
/home/tbade/gocode/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/devices (from $GOPATH)
/home/tbade/gocode/src/github.com/opencontainers/runc/libcontainer/devices
main_unix.go:5:8: cannot find package „github.com/opencontainers/runc/libcontainer/nsenter“ in any of:
/usr/lib/go/src/pkg/github.com/opencontainers/runc/libcontainer/nsenter (from $GOROOT)
/home/tbade/gocode/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/nsenter (from $GOPATH)
/home/tbade/gocode/src/github.com/opencontainers/runc/libcontainer/nsenter
restore.go:14:2: cannot find package „github.com/opencontainers/runc/libcontainer/utils“ in any of:
/usr/lib/go/src/pkg/github.com/opencontainers/runc/libcontainer/utils (from $GOROOT)
/home/tbade/gocode/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/utils (from $GOPATH)
/home/tbade/gocode/src/github.com/opencontainers/runc/libcontainer/utils
make: *** [all] Error 1

FIX Issue 1

tbade@torbuntu:~/gocode/github.com/opencontainers/runc$ cd Godeps/_workspace/src/github.com/
tbade@torbuntu:~/gocode/github.com/opencontainers/runc/Godeps/_workspace/src/github.com$ ls
Sirupsen codegangsta coreos docker godbus golang syndtr
tbade@torbuntu:~/gocode/github.com/opencontainers/runc/Godeps/_workspace/src/github.com$ mkdir opencontainers
tbade@torbuntu:~/gocode/github.com/opencontainers/runc/Godeps/_workspace/src/github.com$ cd opencontainers/
tbade@torbuntu:~/gocode/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers$ git clone https://github.com/opencontainers/runc
Cloning into ‚runc’…
done
cd $GOPATH/github.com/opencontainers/runc/
make

2. ISSUE

tbade@torbuntu:~/gocode/github.com/opencontainers/runc$ make
go build -o runc .
# github.com/opencontainers/runc/libcontainer/seccomp
Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/seccomp/seccomp.go:71: internal compiler error: unknown etype 0/STRUCT
make: *** [all] Error 2

PROBLEM is go version 1.2 / 1.2.1 which is the default in Mint 17/Ubuntu 14.04 (tested on both)
FIX Issue 2

sudo apt-get remove golang golang-tools
sudo su
cd /usr/local/
wget https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.4.2.linux-amd64.tar.g
rm go1.4.2.linux-amd64.tar.gz
vim /etc/profile
# put inside:
export PATH=$PATH:/usr/local/go/bin

—- Logout / Login … its working afterwards … —-

But now Docker is to old …
Upgrade to latest Docker

sudo apt-get update -y && sudo apt-get upgrade -y

sudo sh -c „echo deb https://get.docker.io/ubuntu docker main >/etc/apt/sources.list.d/docker.list“

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

sudo apt-get -y update

sudo apt-get install -y lxc-docker

# now you can check the docker version, it should be more actual version than 1.0.2
Start first runC

docker version

docker pull ubuntu:latest

docker export $(docker create ubuntu) > ubuntu_latest.tar

mkdir rootfs

tar -C rootfs -xf ubuntu_latest.tar

vim config.json

{
„version“: „0.1.1“,
„platform“: {
„os“: „linux“,
„arch“: „amd64“
},
„process“: {
„terminal“: true,
„user“: „daemon“,
„args“: [
„sh“
],
„env“: [
„PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin“,
„TERM=xterm“
],
„cwd“: „“
},
„root“: {
„path“: „rootfs“,
„readonly“: true
},
„hostname“: „shell“,
„mounts“: [
{
„type“: „proc“,
„source“: „proc“,
„destination“: „/proc“,
„options“: „“
},
{
„type“: „tmpfs“,
„source“: „tmpfs“,
„destination“: „/dev“,
„options“: „nosuid,strictatime,mode=755,size=65536k“
},
{
„type“: „devpts“,
„source“: „devpts“,
„destination“: „/dev/pts“,
„options“: „nosuid,noexec,newinstance,ptmxmode=0666,mode=0620,gid=5“
},
{
„type“: „tmpfs“,
„source“: „shm“,
„destination“: „/dev/shm“,
„options“: „nosuid,noexec,nodev,mode=1777,size=65536k“
},
{
„type“: „mqueue“,
„source“: „mqueue“,
„destination“: „/dev/mqueue“,
„options“: „nosuid,noexec,nodev“
},
{
„type“: „sysfs“,
„source“: „sysfs“,
„destination“: „/sys“,
„options“: „nosuid,noexec,nodev“
}
],
„linux“: {
„namespaces“: [
{
„type“: „process“
},
{
„type“: „network“
},
{
„type“: „mount“
},
{
„type“: „ipc“
},
{
„type“: „uts“
}
],
„capabilities“: [
„AUDIT_WRITE“,
„KILL“,
„NET_BIND_SERVICE“
],
„devices“: [
„null“,
„random“,
„full“,
„tty“,
„zero“,
„urandom“
]
}
}

sudo runc

# now you can check if you are inside of runc … with ps

IRCD inside Docker HowTo

This HowTo is to explain how to install an IRC Server inside of a Docker Container,
for testing purposes I also installed vim (just take a look at the Dockerfile …) but it was
for testing only, you can leave it out.

1. Become root
2. Type in:
docker info (just to see if docker is installed)
if „command not found“ shows up, you have to install docker-io
3. create a new folder to store config files (to copy inside the container) and the Dockerfile
(config file for docker to build images)
mkdir -pv ~/Dockerfiles/ircd
cd ~/Dockerfiles/ircd
create an ircd.conf
(a lot of examples can be found on net, this HowTo should not show,
how to configure ircd, it should show, how to create own Docker Container)

IRCD inside Docker HowTo weiterlesen