Code Monkey home page Code Monkey logo

vocker's Introduction

Docker Repository on Quay

vocker - Create VMs not containers

vocker can read Dockerfiles (currently just a subset), and does build VM images from them.

Instead of using the docker registry for base images, virt-builder images can be used as FROM sources.

vocker is building the images incerementally, for each command. It caches the images, which makes it fast.

Note: This is WIP. Not all features are supported (yet).

A quick demo:

asciicast

With more details:

asciicast

Installation

$ pip install -rrequirements.txt
$ yum install virt-install
$ python setup.py install

Usage

The usage should look familiar:

$ vocker build --tag simple -f examples/Dockerfile.simple
$ vocker run simple
fast_fedora
$ vocker attach fast_fedora

# Export an image
$ vocker export simple -f simple.raw

Kubernetes Vocker Builder Usage

In addition to the stock vocker tool, there is also a container and manifest to run vocker as a builder inside a Kubernetes cluster.

The use-case is to use vocker, to build an VM image "onto" a block PV. The job definition is kept in the manifests/ directory.

In order to build a specific image, a vockerfile was to be written into the vocker-job-source ConfigMap. The ConfigMap is mapping a key to a vockerfile. The key will be used as the resulting image filename, which will be written on to the target PV, which is also defined in the Job definition.

In order to build you custom images, you need to complete the following steps:

  1. Add entry to ConfigMap
  2. Adjust Job to point to the PV to be populated
  3. Run job to generate images

An example ConfigMap (the name is relevant):

apiVersion: v1
kind: ConfigMap
metadata:
  name: vocker-job-source
data:
  Fedora: |
    FROM fedora:26
    
    MAINTAINER "Fabian Deutsch" <[email protected]>
    ENV container docker
    
    RUN echo Hello > /marker
    
    EXPOSE 1234
    
    CMD echo World >> /marker

  Ubuntu: |
    FROM ubuntu-16.04

This ConfigMap would build two images Fedora and Ubuntu.

The usage then looks like:

$ kubectl apply -f manifests/vocker-builder-wo-presets.yaml
$ kubectl describe job vocker-builder
Name:           vocker-builder
Namespace:      default
Selector:       controller-uid=ea99dbe6-fa05-11e7-a917-48b8902b170b
Labels:         controller-uid=ea99dbe6-fa05-11e7-a917-48b8902b170b
                job-name=vocker-builder
                role=vocker-job
Annotations:    ...
Parallelism:    1
Completions:    1
Start Time:     Mon, 15 Jan 2018 16:08:17 +0100
Pods Statuses:  0 Running / 1 Succeeded / 0 Failed
Pod Template:
  Labels:  controller-uid=ea99dbe6-fa05-11e7-a917-48b8902b170b
           job-name=vocker-builder
           role=vocker-job
  Containers:
   vocker:
    Image:        quay.io/fabiand/vocker
    Port:         <none>
    Environment:  <none>
    Mounts:
      /source from vocker-source (rw)
      /target from vocker-target (rw)
  Volumes:
   vocker-source:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      vocker-job-source
    Optional:  false
   vocker-target:
    Type:    EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:  
Events:
  Type    Reason            Age   From            Message
  ----    ------            ----  ----            -------
  Normal  SuccessfulCreate  40m   job-controller  Created pod: vocker-builder-xkckj

Once the pod has completed it's work, the image is ready on the PV.

Hacking

When in the source folder:

$ pip install -rrequirements-dev.txt

to install the dependencies.

$ python setup.py test

to run the tests.

$ python vocker.py --help

to run your local developer version.

Why?

I think it's a nice approach to have a declarative approach for creating VMs.

Tips

Setting the root password

By default a random root password is chosen. If you have to set the password during build time you can add the build instruction

RUN echo "mypass" | passwd --stdin

vocker's People

Contributors

fabiand avatar marsik avatar rmohr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vocker's Issues

Fedora 23 image is corrupted (examples/Dockerfile.simple)

I get an error when trying the example like this:

vocker --debug build --tag simple -f ~/vocker/examples/Dockerfile.simple

or this

/usr/bin/virt-builder --format=qcow2 --no-check-signatures -o /root/.cache/vocker/images/fedora-23.qcow2 fedora-23

The error in both cases is:

virt-builder: mount: /dev/sda3 on / (options: ''): mount: wrong fs type, bad option, bad superblock on /dev/sda3,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so. (ignored)
virt-builder: mount: mount: /boot: No such file or directory (ignored)
virt-builder: error: libguestfs error: is_dir: is_dir_stub: you must call 
'mount' first to mount the root filesystem

If reporting bugs, run virt-builder with debugging enabled and include the 
complete output:

  virt-builder -v -x [...]
  • My SELinux is in Permissive mode
  • I have a+x set for the /root hierarchy
  • Trying the same with Fedora 22 works fine.

Access to qcow images is denied`

When building a VM vocker can't access the downloaded images because it tries to access it with the qemu user but the images are stored in the home directory of a user with the according permissions:

RAN: '/bin/virt-builder --format=qcow2 -o /root/.cache/vocker/images/fedora-23.qcow2 fedora-23'

  STDOUT:
[   1.9] Downloading: http://libguestfs.org/download/builder/fedora-23.xz
[   2.5] Planning how to build this image
[   2.5] Uncompressing
[  15.9] Converting raw to qcow2
[  25.2] Opening the new disk


  STDERR:
virt-builder: error: libguestfs error: could not create appliance through 
libvirt.

Try running qemu directly without libvirt using this environment variable:
export LIBGUESTFS_BACKEND=direct

Original error from libvirt: Cannot access storage file 
'/root/.cache/vocker/images/fedora-23.qcow2' (as uid:107, gid:107): 
Permission denied [code=38 int1=13]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.