LoginSignup
17
19

More than 5 years have passed since last update.

Docker Provider VS Docker Provisioner

Last updated at Posted at 2014-07-17

Docker Provider

Vagrantfile
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
$ vagrant up --provider docker
$ nc localhost 8080
hello world!

Docker Provisioner

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "hello-world"

  config.vm.box = "yungsang/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
$ vagrant up
$ nc localhost 8080
hello world!
17
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
19