runc in 30 seconds

runC is a CLI tool produced through the Open Container Project for spawning and running containers without having to run a Docker daemon. It makes use of libcontainer which powers the Docker Engine.

Let's take 30 seconds to try it out.

What you need:

  • runc package or binary installed
  • A root filesystem

runc package

I'm using Arch Linux which has runc available in the package repository and is installed along with Docker 1.11.

$ sudo pacman -Sy runc

For Ubuntu 16.04 use apt:

sudo apt install runc  

rootfs

We can either prepare a root-filesystem from scratch, extract one from a Linux distribution's rootfs.tgz file or export one from a container already run in Docker.

Let's extract a rootfs from a Docker image by running a container, then using docker export.

$ docker run --name node4 mhart/alpine-node:4 node
$ docker export node4 > rootfs.tar
$ mkdir -p ./rootfs
$ tar -xf rootfs.tar -C ./rootfs

Now generate a config file for runc and start the container. You will be given a Node.js REPL.

$ runc spec

Finally, pick a name for the new container and run it as root or sudo - launch node and try out a few commands:

$ sudo runc start node4_repl
/ # node
> process.version
'v4.4.1'  
> 

Running the example on my machine:

Running the example in bash.

Learn more

Both runc and Docker make use of libcontainer but have very different CLIs. If you would like to learn more about how to customise runc, add networking and much more then check out the official homepage at: runc.io or the Github repo.

Popular on the blog this week:

Alex Ellis

Read more posts by this author.

United Kingdom http://alexellis.io/

Subscribe to alex ellis' blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!