Skip to content

Instantly share code, notes, and snippets.

@YungSang
Last active September 5, 2024 22:33
Show Gist options
  • Save YungSang/60fb7d026692e4754123 to your computer and use it in GitHub Desktop.
Save YungSang/60fb7d026692e4754123 to your computer and use it in GitHub Desktop.
Docker Provider VS Docker Provisioner
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "boot2docker", autostart: false do |b2d|
b2d.vm.box = "yungsang/boot2docker"
b2d.nfs.functional = false
b2d.vm.network :forwarded_port, guest: 8080, host: 8080
end
config.vm.define "hello-world", primary: true do |v|
v.vm.provider "docker" do |d|
d.vagrant_vagrantfile = "./Vagrantfile"
d.vagrant_machine = "boot2docker"
d.image = "yungsang/busybox"
d.name = "hello-world"
d.ports = ["8080:80"]
d.cmd = ["nc", "-p", "80", "-l", "-l", "-e", "echo", "hello world!"]
end
end
end
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "hello-world"
config.vm.box = "boot2docker"
config.vm.network :forwarded_port, guest: 8080, host: 8080
config.vm.provision :docker do |d|
d.run "hello-world",
image: "yungsang/busybox",
args: "-p 8080:80",
cmd: "nc -p 80 -l -l -e echo hello world!"
end
end
@YungSang
Copy link
Author

$ vagrant up --provider docker
$ nc localhost 8080
hello world!
$ vagrant up
$ nc localhost 8080
hello world!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment