2014-03-27 35 views
0

我有以下Vagrantfile奇怪的流浪誤差泊塢窗和外殼供應方

VAGRANTFILE_API_VERSION = "2" 

$script = <<SCRIPT 
    apt-get install -y mongodb 
    mongo dummydb -u admin -p admin --eval "db.addUser('dummyuser', 'dummypass')" 
SCRIPT 

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 
    config.vm.box = "precise64" 
    config.vm.box_url = "http://files.vagrantup.com/precise64_vmware_fusion.box" 

    # MongoDB ports 
    config.vm.network "forwarded_port", guest: 27017, host: 27017 

    # RabbitMQ ports 
    config.vm.network "forwarded_port", guest: 5672, host: 5672 
    config.vm.network "forwarded_port", guest: 55672, host: 55672 

    config.vm.provision "docker" do |docker| 
    docker.run "tutum/mongodb", daemonize: true, args: "-p 27017:27017 -e MONGODB_PASS=\"admin\"" 
    docker.run "tutum/rabbitmq", daemonize: true, args: "-p 5672:5672 -p 55672:55672 -e RABBITMQ_PASS=\"admin\"" 
    end 

    # config.vm.provision "shell", inline: $script 
end 

當我運行這個使用

$ vagrant up --provider=vmware_fusion 

這個完美的作品:創建虛擬機,安裝泊塢窗和MongoDB以及RabbitMQ都已設置,並且相應地分配了密碼。到目前爲止,一切都很好。

當我現在取消註釋執行該外殼供應方(其中,根據documentation,應該像這樣),我得到一個非常奇怪的錯誤的最後一行:放浪安裝泊塢窗,拉tutum/mongodb圖像,然後告訴我,運行容器失敗:

==> default: Starting Docker containers... 
==> default: -- Container: tutum/mongodb 
The following SSH command responded with a non-zero exit status. 
Vagrant assumes that this means the command failed! 

      rm -f /var/lib/vagrant/cids/1bef9ddec8969e37432fbe8c55f6d9452cd61e4a 
      docker run -cidfile=/var/lib/vagrant/cids/1bef9ddec8969e37432fbe8c55f6d9452cd61e4a -d -name tutum/mongodb -p 27017:27017 -e MONGODB_PASS="admin" tutum/mongodb 

Stdout from the command: 

Stderr from the command: 

stdin: is not a tty 
Warning: '-cidfile' is deprecated, it will be replaced by '--cidfile' soon. See usage. 
Warning: '-name' is deprecated, it will be replaced by '--name' soon. See usage. 
Unable to find image 'tutum/mongodb' locally 
Pulling repository tutum/mongodb 

2014/03/27 01:31:40 Error: Invalid container name (tutum/mongodb), only [a-zA-Z0-9_.-] are allowed 

我想這個問題是參數-name tutum/mongodb是流浪自動適用於docker run通話。

我不明白的是爲什麼會這樣只有如果我添加外殼供應方(這顯然什麼做設置泊塢或碼頭集裝箱)。

有沒有人有這個想法?

我在OS X 10.9.2上使用了Vagrant 1.5.1,Vagrant VMWare Fusion provider 2.3.4和VMWare 6.0.2。

有沒有人有一個想法可能會導致這個問題,以及如何解決它?

PS:我目前的解決方法是在Vagrantfile內應用auto_assign_name: false,但這只是一種解決方法。我很好奇實際問題是什麼以及如何正確解決問題。

回答

3

碼頭正在抱怨,因爲單-而不是雙-。檢查the docs爲新的方式來指定它們。

要成功運行該命令使用

docker run --cidfile=/var/lib/vagrant/cids/1bef9ddec8969e37432fbe8c55f6d9452cd61e4a -d --name="tutum/mongodb" -p 27017:27017 -e MONGODB_PASS="admin" tutum/mongodb 

但是,解決在流浪者將需要一個核心供應者代碼更新。

更新

這已被固定在1.5.2版本中,看着this commit看來,他們正在使用--name--cidfile現在。

+0

但是,這不僅是缺少的短跑,它也是缺少的引號,不是嗎? –

+0

是的,但它們是可選的。這個想法是,在Docker語法級別有一個棄用需要Vagrant社區的支持。儘管如此,我希望自己達到了Ruby語言的水平,以幫助實現這一目標。 – Mulkave