Skip to content

Instantly share code, notes, and snippets.

@ybootin ybootin/Vagrantfile forked from michaelsauter/Vagrantfile
Last active Aug 29, 2015

Embed
What would you like to do?

Docker Mac binary:

curl -L -o docker https://get.docker.io/builds/Darwin/x86_64/docker-latest
chmod +x docker
sudo mv docker /usr/local/bin/docker

Install nsenter in the box:

docker run --rm -v /var/lib/boot2docker/:/target jpetazzo/nsenter

Put this next to your Vagrantfile:

#!/bin/sh

vagrant ssh -c "sudo /var/lib/boot2docker/docker-enter $1"

Use it: ./docker-enter container_name

VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.6.3"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "boot2docker"
config.vm.box = "yungsang/boot2docker"
config.vm.box_check_update = false
config.vm.network "private_network", ip: "192.168.33.10"
# Mount current dir under same path in VM
config.vm.synced_folder ".", Dir.pwd, type: "nfs", mount_options: ["nolock", "vers=3", "udp"]
config.vm.provider :virtualbox do |vb, override|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
# Fix busybox/udhcpc issue
config.vm.provision :shell do |s|
s.inline = <<-EOT
if ! grep -qs ^nameserver /etc/resolv.conf; then
sudo /sbin/udhcpc
fi
cat /etc/resolv.conf
EOT
end
# Adjust datetime after suspend and resume
config.vm.provision :shell do |s|
s.inline = <<-EOT
sudo /usr/local/bin/ntpclient -s -h pool.ntp.org
date
EOT
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.