ns-process
Code to accompany the "Namespaces in Go" series of articles.
- Part 1: Linux Namespaces
- Part 2: Namespaces in Go - Basics
- Part 3: Namespaces in Go - User
- Part 4: Namespaces in Go - reexec
- Part 5: Namespaces in Go - Mount
- Part 6: Namespaces in Go - Network
- Part 7: Namespaces in Go - UTS
Environment Preparation
For mac users, the simplest way to setup an environment is using Vagrant.
vagrant init ubuntu/xenial64
vagrant up
vagrant ssh
Install go
apt install golang-go
Setup GOPATH
export GOPATH=$(pwd)
Get extra packages
go get github.com/docker/docker/pkg/reexec
Build now
go build
Install netsetgo
wget "https://github.com/teddyking/netsetgo/releases/download/0.0.1/netsetgo"
sudo mv netsetgo /usr/local/bin/
sudo chown root:root /usr/local/bin/netsetgo
sudo chmod 4755 /usr/local/bin/netsetgo
Get a root fs
wget "https://raw.githubusercontent.com/teddyking/ns-process/4.0/assets/busybox.tar"
mkdir -p /tmp/ns-process/rootfs
tar -C /tmp/ns-process/rootfs -xf busybox.tar
Usage
Each of the code extracts in the articles reference a git tag, which can be checked out from this repo. The code is buildable and runnable at each tag, but note that it will only run successfully on Linux machines.
Testing
The test suite isn't explicitly mentioned in the articles, but if you'd like to run the tests you'll need to install ginkgo and gomega. Note that some of the tests may require root privileges.