How to use Vagrant Docker provisioner with PowerKVM

Vagrant provisioners allow software installation, configuration changes and other changes to the machines. Vagrant provides multiple provisioners, starting from simple shell scripts to complete configuration management systems, like chef, puppet, ansible etc.

Provisioners get executed at specific points during the lifetime of a Vagrant machine.

From Vagrant docs,

  • On the first vagrant up that creates the environment, provisioning is run. If the environment was already created and the up is just resuming a machine or booting it up, they won’t run unless the –provision flag is explicitly provided.
  • When vagrant provision is used on a running environment.
  • When vagrant reload –provision is called. The –provision flag must be present to force provisioning.

In this article, we’ll see how to use the Vagrant docker provisioner with PowerKVM.

My setup looks like the following

In order to create Vagrant machines on PowerKVM you need to use the vagrant-libvirt plugin. For more details on using vagrant-libvirt plugin with PowerKVM refer to my previous article.

Using the docker provisioner with PowerKVM is pretty straight forward.

Here is a sample Vagrantfile for creating docker containers on PowerKVM VM created by vagrant-libvirt.

[pradipta@voldemort vagrant-box]$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # All Vagrant configuration is done here. The most common configuration
  # options are documented and commented below. For a complete reference,
  # please see the online documentation at
  config.vm.provider :libvirt do |libvirt| = ""
       libvirt.connect_via_ssh = "true"
       libvirt.uri = "qemu+ssh://"
       libvirt.management_network_name = "default"
       libvirt.management_network_address = ""

  config.vm.define :test_vagrant do |test1| = "trustyppc64"
    test1.vm.box_url = ""
    test1.vm.provider :libvirt do |domain|
      domain.memory = 2048
      domain.cpus = 1
      domain.video_type = "vga"
 #Install docker for Ubuntu ppc64 from custom location 
  config.vm.provision "shell", path: ""

 #Download a docker image and run it via the docker provisioner
  config.vm.provision "docker" do |d|
     d.pull_images "my.private.docker.registry/pradipta/ubuntu_ppc64le" "ubuntu_ppc64le",
         image: "my.private.docker.registry/pradipta/ubuntu_ppc64le”,
         cmd: "cat /etc/lsb-release"

   #Check the container logs
  config.vm.provision "shell" do |s|
    s.inline = "sudo docker logs ubuntu_ppc64le"
end is a simple shell script to download docker for Ubuntu ppc64 from Unicamp repository. This is required currently till docker becomes part of official distro repository for Power. For more details on docker on Ubuntu for Power servers check my previous article on the same topic.

[pradipta@voldemort vagrant-box]$ cat
RET=`dpkg -s 2>/dev/null`
if [ $? != 0 ]
    #Download docker binary for Ubuntu on Power from Unicamp site
    sudo dpkg -i

In my case the vagrant machine is already running. Hence explicitly starting the provisioning by calling ‘vagrant provision’

[pradipta@voldemort libvirt]$ vagrant provision
==> test1: Running provisioner: shell...
    test1: Running: /tmp/
==> test1: Running provisioner: docker...
    test1: Configuring Docker to autostart containers...
==> test1: Pulling Docker images...
==> test1: Starting Docker containers...
==> test1: -- Container: ubuntu_ppc64le
==> test1: Running provisioner: shell...
    test1: Running: inline script
==> test1: stdin: is not a tty
==> test1: DISTRIB_ID=Ubuntu
==> test1: DISTRIB_RELEASE=14.04
==> test1: DISTRIB_CODENAME=trusty
==> test1: DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"

As you can see using Vagrant Docker provisioner with PowerKVM is pretty straight-forward.

Pradipta Kumar Banerjee

I'm a Cloud and Linux/ OpenSource enthusiast, with 16 years of industry experience at IBM. You can find more details about me here - Linkedin

You may also like...