Skip to content

Instantly share code, notes, and snippets.

@come-maiz
Created September 6, 2016 15:46
Show Gist options
  • Save come-maiz/30356b6df2969c64a41d6ad71c0f8cce to your computer and use it in GitHub Desktop.
Save come-maiz/30356b6df2969c64a41d6ad71c0f8cce to your computer and use it in GitHub Desktop.
runc snap testing

Smoke tests for the runc snap

First, build and install the runc snap:

  1. git clone https://github.com/elopio/runc
  2. cd runc
  3. git checkout snapcraft
  4. sudo apt install snapcraft
  5. snapcraft
  6. sudo snap install runc*.snap

Print the help:

$ runc
$ runc help
$ runc h
$ runc -h
$ runc --help
NAME:
   runc - Open Container Initiative runtime
[...]

Print the version:

$ runc --version
$ runc -v
 runc version 0.1.1
spec: 0.6.0-dev

Install docker, required for the next step:

$ `sudo apt install docker.io`

Create an OCI bundle: (The snap only has permission to write to its own home directory, so we create the bundle there. If this is the first time you install the runc snap, then $REVISION will be x1.)

$ mkdir $HOME/snap/runc/$REVISION/container
$ cd $HOME/snap/runc/$REVISION/container
$ mkdir rootfs
$ sudo docker export $(sudo docker create busybox) | tar -C rootfs -xvf -

Docker has the runc deb package as a dependency. To make sure that we are running runc from the snap, uninstall the deb:

$ sudo apt remove runc

Generate a spec:

$ runc spec
$ cat config.json
{
    "ociVersion": "1.0.0-rc1",
    "platform": {
	    "os": "linux",
	    "arch": "amd64"
    },
  [...]

Run the container:

$ runc run testcontainer
@come-maiz
Copy link
Author

I have problems to run the container:

$ runc run testcontainer
runc should be run as root
$ sudo runc run testcontainer
open config.json: permission denied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment