6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Re: Dongri's Blog - docker-sharing

Posted at

Dongri's Blog - docker-sharing 用の Vagrantfile はこんな感じでどうでしょうか?

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "boot2docker"

  config.vm.box = "yungsang/boot2docker"

  config.vm.network :forwarded_port, guest: 2375, host: 4243, disabled: true

  config.vm.network :private_network, ip: "192.168.33.10"

  config.vm.synced_folder ".", "/var/app", type: "nfs"

  # 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

  config.vm.provision :shell do |s|
    s.inline = <<-EOT
      docker rm -f nodejs || true
    EOT
  end

  config.vm.provision :docker do |d|
    d.build_image "/var/app/node/", args: "-t dongri/node"
    d.run "nodejs", image: "dongri/node", args: "-p 3000:3000"
  end

  config.vm.network :forwarded_port, guest: 3000, host: 3000
end
$ git clone git@github.com:dongri/Dockerfiles.git
$ cd Dockerfiles
$ edit Vagrantfile
$ vagrant up
$ open http://localhost:3000

あとはコードを修正したら vagrant provision をやる感じで。

6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?