-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile
52 lines (40 loc) · 1.7 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'pathname'
configfile = Pathname.new(File.expand_path('../config.rb', __FILE__))
if configfile.exist?
load configfile.path
end
$vm_cpu ||= 4
$vm_ram ||= 3048
$vm_ip ||= '192.168.33.42'
Vagrant.configure('2') do |vagrant|
vagrant.vm.define 'docker' do |config|
config.vm.box = 'goodguide/docker-vagrant'
config.vm.box_version = '>= 0.0.1'
config.vm.network "private_network", ip: $vm_ip
# Mount your home directory in the VM at the same path, so absolute paths to
# directories you want to add as mounted volumes are resolvable both inside
# and outside the container.
config.vm.synced_folder ENV['HOME'], ENV['HOME'], type: 'nfs'
# Disable the default /vagrant share, as it's not really applicable
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.provider "virtualbox" do |vb|
# Use VBoxManage to customize the VM. For example to change memory:
vb.memory = $vm_ram
vb.cpus = $vm_cpu
end
config.vm.provision :docker
config.vm.provision :shell, privileged: true, inline: <<-SHELL
echo 'DOCKER_OPTS="-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375"' > /etc/default/docker
service docker restart
SHELL
config.vm.post_up_message = <<-MSG.split("\n").map{|l| " #{l[6..-1]}" }.join("\n")
With the docker client installed on your host machine, you can now use Docker as
you'd expect, by simply telling it where to find the docker daemon:
$ export DOCKER_HOST='tcp://#{$vm_ip}:2375'
$ docker ps
Additionally, many GG tools/docs expect you to add an entry to /etc/hosts for
this VM. Add this line to your /etc/hosts file:
#{$vm_ip} docker.dev
MSG
end
end