virtc

command
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2016 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

virtc

virtc is a simple command-line tool that serves to demonstrate typical usage of the virt API. This is example software; unlike other projects like runc, runv, or rkt, virt is not a full container runtime.

Virtc example

Here we explain how to use the pod API from virtc command line.

Prepare your environment
Get your kernel

Fedora

$ sudo -E dnf config-manager --add-repo http://download.opensuse.org/repositories/home:clearlinux:preview:clear-containers-2.0/Fedora_24/home:clearlinux:preview:clear-containers-2.0.repo
$ sudo dnf install linux-container 

Ubuntu

$ sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/clearlinux:/preview:/clear-containers-2.0/xUbuntu_16.04/ /' >> /etc/apt/sources.list.d/cc-oci-runtime.list"
$ sudo apt install linux-container
Get your image

It has to be a recent Clear Linux image to make sure it contains hyperstart binary. You can dowload the following tested image, or any version more recent.

$ wget https://download.clearlinux.org/releases/11130/clear/clear-11130-containers.img.xz
$ unxz clear-11130-containers.img.xz
$ sudo cp clear-11130-containers.img /usr/share/clear-containers/clear-containers.img
Get virtc

Download virtc

$ go get github.com/containers/virtcontainers

Build virtc

$ cd $GOPATH/src/github.com/containers/virtcontainers
$ cd virtc && go build
Run virtc

All following commands needs to be run as root. Currently, virtc only starts single container pods.

Create your container bundle

As an example we will create a busybox bundle:

$ mkdir -p /tmp/bundles/busybox/
$ docker pull busybox
$ cd /tmp/bundles/busybox/
$ mkdir rootfs
$ docker export $(docker create busybox) | tar -C rootfs -xvf -
$ echo -e '#!/bin/sh\ncd "\"\n"sh"' > rootfs/.containerexec
$ echo -e 'HOME=/root\nPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\nTERM=xterm' > rootfs/.containerenv
Run a new pod (Create + Start)
./virtc pod run --bundle="/tmp/bundles/busybox/rootfs" --agent="hyperstart" --init-cmd="/bin/sh"
Create a new pod
./virtc pod create --bundle="/tmp/bundles/busybox/rootfs" --agent="hyperstart" --init-cmd="/bin/sh"

This should generate that kind of output

Created pod 306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
Start an existing pod
./virtc pod start --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
Stop an existing pod
./virtc pod stop --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
Get the status of an existing pod and its containers
./virtc pod status --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8

This should generate the following output:

POD ID                                  STATE   HYPERVISOR      AGENT
306ecdcf-0a6f-4a06-a03e-86a7b868ffc8    running qemu            hyperstart

CONTAINER ID    STATE
1               ready
Delete an existing pod
./virtc pod delete --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
List all existing pods
./virtc pod list

This should generate that kind of output

POD ID                                  STATE   HYPERVISOR      AGENT
306ecdcf-0a6f-4a06-a03e-86a7b868ffc8    running qemu            hyperstart
92d73f74-4514-4a0d-81df-db1cc4c59100    running qemu            hyperstart
7088148c-049b-4be7-b1be-89b3ae3c551c    ready   qemu            hyperstart
6d57654e-4804-4a91-b72d-b5fe375ed3e1    ready   qemu            hyperstart

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL