Skip to content

Instantly share code, notes, and snippets.

@ybootin
Forked from michaelsauter/Vagrantfile
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ybootin/880164498734c27a54c6 to your computer and use it in GitHub Desktop.
Save ybootin/880164498734c27a54c6 to your computer and use it in GitHub Desktop.

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