Vagrantが1.4.1になって、Redhat、CentOSでもdockerのproviderが動くようになったということで、試してみた。
Vagrant 1.4.1 has been released. Bug fixes with one big improvement: Docker provisioner works on RedHat guests! http://t.co/EmB5qlwpBa
— Mitchell Hashimoto (@mitchellh) 2013, 12月 18
結果
とりあえず動かしてみることは簡単にできた。
事前準備
Vagrantfileを作る
実行
vagrant up
こんな感じでdockerのコンテナができていることを確認
[otahi@otahiair test-docker-vagrant]$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... [default] Box 'centos65' was not found. Fetching box from specified URL for the provider 'virtualbox'. Note that if the URL does not have a box for this provider, you should interrupt Vagrant now and add the box yourself. Otherwise Vagrant will attempt to download the full box prior to discovering this error. Downloading box from URL: https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box Extracting box...te: 660k/s, Estimated time remaining: --:--:--) Successfully added box 'centos65' with provider 'virtualbox'! [default] Importing base box 'centos65'... [default] Matching MAC address for NAT networking... [default] Setting the name of the VM... [default] Clearing any previously set forwarded ports... [default] Fixed port collision for 22 => 2222. Now on port 2200. [default] Clearing any previously set network interfaces... [default] Preparing network interfaces based on configuration... [default] Forwarding ports... [default] -- 22 => 2200 (adapter 1) [default] Booting VM... [default] Waiting for machine to boot. This may take a few minutes... [default] Machine booted and ready! [default] The guest additions on this VM do not match the installed version of VirtualBox! In most cases this is fine, but in rare cases it can cause things such as shared folders to not work properly. If you see shared folder errors, please make sure the guest additions within the virtual machine match the version of VirtualBox you have installed on your host and reload your VM. Guest Additions Version: 4.3.4 VirtualBox Version: 4.2 [default] Mounting shared folders... [default] -- /vagrant [default] Running provisioner: docker... [default] Installing Docker (latest) onto machine... [default] Pulling Docker images... [default] -- Image: centos [otahi@otahiair test-docker-vagrant]$ vagrant ssh [vagrant@vagrant-centos65 ~]$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos 6.4 539c0211cd76 8 months ago 300.6 MB (virtual 300.6 MB) centos latest 539c0211cd76 8 months ago 300.6 MB (virtual 300.6 MB) [vagrant@vagrant-centos65 ~]$ sudo docker run centos echo hello hello [vagrant@vagrant-centos65 ~]$