├── .gitignore ├── Makefile ├── README.md ├── Vagrantfile ├── download.sh ├── readme_image.gif ├── template.json └── vagrantfile.tpl /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vagrant/ 3 | packer_cache/ 4 | *.box 5 | boot2docker.iso 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | build: boot2docker-vagrant.iso 2 | time (packer build -parallel=false template.json) 3 | 4 | prepare: clean boot2docker-vagrant.iso 5 | 6 | boot2docker-vagrant.iso: 7 | vagrant up 8 | vagrant ssh -c 'cd /vagrant && sudo ./build-iso.sh' 9 | vagrant destroy --force 10 | 11 | clean: 12 | rm -rf *.iso *.box 13 | 14 | .PHONY: clean prepare build 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # boot2docker Vagrant Box 2 | 3 | This repository contains the scripts necessary to create a Vagrant-compatible 4 | [boot2docker](https://github.com/steeve/boot2docker) box. If you work solely 5 | with Docker, this box lets you keep your Vagrant workflow and work in the 6 | most minimal Docker environment possible. 7 | 8 | ## Usage 9 | 10 | The box is available on 11 | [Vagrant Cloud](https://vagrantcloud.com/mitchellh/boot2docker), making 12 | it very easy to use it: 13 | 14 | $ vagrant init mitchellh/boot2docker 15 | $ vagrant up 16 | 17 | If you want the actual box file, you can download it from the 18 | [releases page](https://github.com/mitchellh/boot2docker-vagrant-box/releases). 19 | 20 | On OS X, to use the docker client, follow the directions here: 21 | http://docs.docker.io/installation/mac/#docker-os-x-client (you'll need to 22 | export `DOCKER_HOST`). You should then be able to to run `docker version` from 23 | the host. 24 | 25 | ![Vagrant Up Boot2Docker](https://raw.github.com/mitchellh/boot2docker-vagrant-box/master/readme_image.gif) 26 | 27 | ## Building the Box 28 | 29 | If you want to recreate the box, rather than using the binary, then 30 | you can use the scripts and Packer template within this repository to 31 | do so in seconds. 32 | 33 | To build the box, first install the following prerequisites: 34 | 35 | * [Packer](http://www.packer.io) (at least version 0.5.1) 36 | * [VirtualBox](http://www.virtualbox.org) (at least version 4.3), VMware, or Parallels 37 | * [Vagrant](http://www.vagrantup.com) 38 | 39 | Then follow the steps: 40 | 41 | ``` 42 | $ vagrant up 43 | ... 44 | $ vagrant ssh -c 'cd /vagrant && sudo ./build-iso.sh' 45 | ... 46 | $ vagrant destroy --force 47 | ... 48 | $ packer build template.json 49 | ... 50 | ``` 51 | 52 | You can restrict only VirtualBox, VMware, or Parallels by specifying the `-only` flag 53 | to Packer. 54 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | # All Vagrant configuration is done here. The most common configuration 9 | # options are documented and commented below. For a complete reference, 10 | # please see the online documentation at vagrantup.com. 11 | 12 | # Every Vagrant virtual environment requires a box to build off of. 13 | config.vm.box = "chef/ubuntu-12.04-i386" 14 | 15 | config.vm.provider "virtualbox" do |v| 16 | v.customize ["modifyvm", :id, "--memory", "1500"] 17 | end 18 | 19 | config.vm.provider "parallels" do |v, override| 20 | override.vm.box = "parallels/ubuntu-12.04" 21 | v.memory = 1500 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | FILENAME="boot2docker.iso" 5 | URL="$1" 6 | CHECKSUM="$2" 7 | 8 | # If the file exists, check the checksum to see if we have to redownload it. 9 | # Otherwise, just exit 0 because we have it. 10 | if [ -f "${FILENAME}" ]; then 11 | ACTUAL=$(shasum -a256 $FILENAME | awk '{print $1}') 12 | if [ "x${ACTUAL}" = "x${CHECKSUM}" ]; then 13 | echo "Checksums match. Not redownloading." 14 | exit 0 15 | fi 16 | fi 17 | 18 | echo "Downloading..." 19 | curl -L ${URL} > ${FILENAME} 20 | -------------------------------------------------------------------------------- /readme_image.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitchellh/boot2docker-vagrant-box/60c657b25111c5b8a0dc03e1daa74e2dc3a20300/readme_image.gif -------------------------------------------------------------------------------- /template.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "url": "https://github.com/boot2docker/boot2docker/releases/download/v1.7.0/boot2docker.iso", 4 | "checksum": "3ebc29aecabc990c4303b9cc6ab26fa8acc673bfbfae3f2fbd8d827c0ff48183", 5 | "version": "1.7", 6 | "number": "{{env `ATLAS_BUILD_NUMBER`}}" 7 | }, 8 | 9 | "builders": [{ 10 | "type": "virtualbox-iso", 11 | "iso_url": "{{user `url`}}", 12 | "iso_checksum_type": "sha256", 13 | "iso_checksum": "{{user `checksum`}}", 14 | "boot_wait": "5s", 15 | "guest_additions_mode": "attach", 16 | "guest_os_type": "Linux_64", 17 | "ssh_username": "docker", 18 | "ssh_password": "tcuser", 19 | "shutdown_command": "sudo poweroff" 20 | }, { 21 | "type": "vmware-iso", 22 | "iso_url": "{{user `url`}}", 23 | "iso_checksum_type": "sha256", 24 | "iso_checksum": "{{user `checksum`}}", 25 | "boot_wait": "5s", 26 | "guest_os_type": "other3xlinux-64", 27 | "ssh_username": "docker", 28 | "ssh_password": "tcuser", 29 | "shutdown_command": "sudo poweroff" 30 | }, { 31 | "type": "parallels-iso", 32 | "iso_url": "{{user `url`}}", 33 | "iso_checksum_type": "sha256", 34 | "iso_checksum": "{{user `checksum`}}", 35 | "boot_wait": "5s", 36 | "guest_os_distribution": "linux", 37 | "ssh_username": "docker", 38 | "ssh_password": "tcuser", 39 | "shutdown_command": "sudo poweroff" 40 | }], 41 | 42 | "provisioners": [{ 43 | "type": "shell-local", 44 | "command": "chmod +x ./download.sh && ./download.sh '{{user `url`}}' {{user `checksum`}}" 45 | }, { 46 | "type": "shell", 47 | "except": ["vmware-iso"], 48 | "inline": [ 49 | "mkfs.ext4 -F -L boot2docker-data /dev/sda", 50 | "sudo mkdir /mnt/sda", 51 | "sudo mount /dev/sda /mnt/sda", 52 | "sudo mkdir -p /mnt/sda/var/lib/boot2docker", 53 | "sudo echo 'export DOCKER_TLS=no' > /tmp/profile", 54 | "sudo mv /tmp/profile /mnt/sda/var/lib/boot2docker/profile", 55 | "sudo chown root:root /mnt/sda/var/lib/boot2docker/profile", 56 | "sync" 57 | ] 58 | }, { 59 | "type": "shell", 60 | "only": ["vmware-iso"], 61 | "inline": [ 62 | "sudo mkdir -p /mnt/sda1/var/lib/boot2docker", 63 | "sudo echo 'export DOCKER_TLS=no' > /tmp/profile", 64 | "sudo mv /tmp/profile /mnt/sda1/var/lib/boot2docker/profile", 65 | "sudo chown root:root /mnt/sda1/var/lib/boot2docker/profile", 66 | "sync" 67 | ] 68 | }], 69 | 70 | "post-processors": [[{ 71 | "type": "vagrant", 72 | "include": ["boot2docker.iso"], 73 | "vagrantfile_template": "vagrantfile.tpl", 74 | "output": "boot2docker_{{.Provider}}.box" 75 | },{ 76 | "type": "atlas", 77 | "only": ["vmware-iso"], 78 | "artifact": "hashicorp/boot2docker", 79 | "artifact_type": "vagrant.box", 80 | "metadata": { 81 | "provider": "vmware_desktop", 82 | "version": "{{user `version`}}.{{user `number`}}", 83 | "description": "boot2docker v{{user `version`}}. The last part of the version is just a build number we increment as we make patch changes to the Vagrant box." 84 | } 85 | },{ 86 | "type": "atlas", 87 | "only": ["virtualbox-iso"], 88 | "artifact": "hashicorp/boot2docker", 89 | "artifact_type": "vagrant.box", 90 | "metadata": { 91 | "provider": "virtualbox", 92 | "version": "{{user `version`}}.{{user `number`}}", 93 | "description": "boot2docker v{{user `version`}}. The last part of the version is just a build number we increment as we make patch changes to the Vagrant box." 94 | } 95 | }]], 96 | 97 | "push": { 98 | "name": "hashicorp/boot2docker", 99 | "vcs": true 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /vagrantfile.tpl: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.ssh.shell = "sh" 3 | config.ssh.username = "docker" 4 | config.ssh.password = "tcuser" 5 | 6 | # Disable synced folders because guest additions aren't available 7 | config.vm.synced_folder ".", "/vagrant", disabled: true 8 | 9 | # Expose the Docker port 10 | config.vm.network "forwarded_port", guest: 2375, host: 2375, 11 | host_ip: "127.0.0.1", auto_correct: true, id: "docker" 12 | 13 | # b2d doesn't support NFS 14 | config.nfs.functional = false 15 | 16 | # b2d doesn't persist filesystem between reboots 17 | if config.ssh.respond_to?(:insert_key) 18 | config.ssh.insert_key = false 19 | end 20 | 21 | # Attach the ISO 22 | config.vm.provider "virtualbox" do |v| 23 | v.customize "pre-boot", [ 24 | "storageattach", :id, 25 | "--storagectl", "IDE Controller", 26 | "--port", "0", 27 | "--device", "1", 28 | "--type", "dvddrive", 29 | "--medium", File.expand_path("../boot2docker.iso", __FILE__), 30 | ] 31 | 32 | # On VirtualBox, we don't have guest additions or a functional vboxsf 33 | # in TinyCore Linux, so tell Vagrant that so it can be smarter. 34 | v.check_guest_additions = false 35 | v.functional_vboxsf = false 36 | end 37 | 38 | ["vmware_fusion", "vmware_workstation"].each do |vmware| 39 | config.vm.provider vmware do |v| 40 | v.vmx["bios.bootOrder"] = "CDROM,hdd" 41 | v.vmx["ide1:0.present"] = "TRUE" 42 | v.vmx["ide1:0.fileName"] = File.expand_path("../boot2docker.iso", __FILE__) 43 | v.vmx["ide1:0.deviceType"] = "cdrom-image" 44 | 45 | if v.respond_to?(:functional_hgfs=) 46 | v.functional_hgfs = false 47 | end 48 | end 49 | end 50 | 51 | config.vm.provider "parallels" do |v| 52 | v.customize "pre-boot", [ 53 | "set", :id, 54 | "--device-add", "cdrom", 55 | "--enable", "--connect", 56 | "--image", File.expand_path("../boot2docker.iso", __FILE__) 57 | ] 58 | v.customize "pre-boot", [ 59 | "set", :id, 60 | "--device-bootorder", "cdrom0 hdd0" 61 | ] 62 | end 63 | end 64 | --------------------------------------------------------------------------------