Skip to content

Using packer on Mac OS X with boot2docker

Hans Hasselberg edited this page Jun 26, 2015 · 2 revisions

Testing berkshelf + docker + packer combo

install packer + berkshelf

#berks vendor ./vendor-cookbooks

Using and development on Mac OS X

Install following packages

Homebrew installable packages

  • docker
  • boot2docker
  • packer

ChefDK from opscode.com

  • chefdk

Installing docker on Mac OS X

Run following commands to start small support vm for docker

boot2docker init
boot2docker up

Starting / creating docker container

There is a problem with using packer on Mac OS X. Where packer is not able to comunicate with docker VM running in boot2docker VM. To make it running use this simple commands. First we need to setup a root password in boot2docker vm docker/tcuser.

boot2docker ssh
sudo passwd root

With root account password set

cd docker-tomcat
packer build template.json

From packer output get description of volume definition for docker container, _/var/folders/yq/h9bmb6x1qxb7p4_w5xhkgx80000gn/T/packer-docker198944115.

2014/05/13 16:32:26 ui:     docker: Run command: docker run -d -i -t -v /var/folders/yq/_h9bmb6x1qxb7p4_w5xhkgx80000gn/T/packer-docker198944115:/packer-files phusion/baseimage:0.9.9 /bin/bash

Because of communication trouble packer will halt on installing chef step. To make it continue user needs to mount boot2docker vm directory /var/folders/yq/_h9bmb6x1qxb7p4_w5xhkgx80000gn/T/packer-docker198944115 to local machine.

packer_dir=packer-docker198944115
umount /var/folders/yq/_h9bmb6x1qxb7p4_w5xhkgx80000gn/T/${packer_dir}
sshfs -p 2022 root@localhost:/var/folders/yq/_h9bmb6x1qxb7p4_w5xhkgx80000gn/T/${packer_dir} /var/folders/yq/_h9bmb6x1qxb7p4_w5xhkgx80000gn/T/${packer_dir}
root@localhost's password:

After mounting fs packer command will continue to build machine and finish the build.