Skip to content

Instantly share code, notes, and snippets.

@egernst
Last active March 13, 2017 21:28
Show Gist options
  • Save egernst/1fa7a59307a9e2068ecbf82949678385 to your computer and use it in GitHub Desktop.
Save egernst/1fa7a59307a9e2068ecbf82949678385 to your computer and use it in GitHub Desktop.
debugging clear containers

#Debug with your own rootfs: Easy setup available to build your own kernel, rootfs and image available at:

$ git clone https://github.com/clearcontainers/osbuilder.git

##Connect to mini-OS: To aid in debug of the mini-os itself, you can create a debug console service and add it to the rootfs. Directions for this can be found at : https://github.com/jcvenegas/cc-oci-runtime/commit/3334a2bc7c915e

After adding the appropriate files, you can connect to the mini-OS via

$ socat STATE_DIR_CONTAINER/console.sock -

where STATE_DIR_CONTAINER by default is /run/cc-oci-runtime/CONTAINER_ID

Note: This will fail if you connect when using a cc-proxy which has a verbosity level >1.

##Building your own hyperstart: For clear containers, hyperstart is used as the agent on the VM. CC project has many changes on top of the 0.7.0 release. This can be obtained via:

$ git clone https://github.com/clearcontainers/hyperstart.git

You build as described:

$ ./autogen.sh
$ ./configure
$ make

The binary that we are interested is hyperstart, which is located post build at src/hyperstart.

This can be copied into the rootfs being used @ /usr/sbin/hyperstart

#Editing rootfs without use of os-builder Once you have a debug image, you can easily modify the rootfs after mounting as follows:

$  sudo losetup --partscan --find --show <path-to-image-under-test>/clear-containers.img /dev/loop0 
$ sudo mount /dev/loop0p1 /mnt/
 ...edit as needed... when done:
$ sudo umount ${DEVICE} #<- ie, dev/loop0
$ fsck -D -y "${DEVICE}p1"
$ losetup -d "${DEVICE}"


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