Docker作为Vagrant的提供者

我正在使用Saltstack / Shellconfiguration一个stream浪机器,但现在我想添加Docker作为提供者。 我有一个超时问题,所以我修改了超时值。 现在看来,这台机器永远不会工作:我一直在等待,没有任何反应!

这是我的stream浪文件:

Vagrant.configure(2) do |config| config.vm.define :nodejs do |nodejs| #nodejs.vm.box = "ubuntu/trusty64" nodejs.vm.hostname = "nodejs" nodejs.ssh.pty = true nodejs.vm.boot_timeout = 50000 nodejs.vm.network "forwarded_port", guest: 80, host: 8001 nodejs.vm.network "forwarded_port", guest: 3600, host: 8002 nodejs.vm.network "private_network", ip: "10.0.0.10" nodejs.vm.synced_folder "salt/roots/", "/srv/salt/" nodejs.vm.synced_folder "salt/minion.d/", "/etc/salt/minion.d/" nodejs.vm.synced_folder "salt/formulas/", "/srv/formulas/" nodejs.vm.provider :virtualbox do |vb| vb.gui = true end nodejs.vm.provision :salt do |salt| salt.verbose = true salt.minion_config = "salt/minion.yml" salt.run_highstate = true salt.colorize = true salt.log_level = 'all' salt.always_install = true salt.colorize = true salt.bootstrap_options = '-F -c /tmp/ -P' end nodejs.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--memory", "2048"] v.customize ["modifyvm", :id, "--cpus", "2"] end nodejs.vm.provision "shell", path: "bootstrap/nodejs_bootstrap.sh" nodejs.ssh.username = 'docker' nodejs.ssh.password = 'tcuser' nodejs.vm.provider :docker do |docker| docker.force_host_vm = true docker.has_ssh = true docker.image = 'ubuntu' docker.remains_running = false end end end 

没有Docker的一切工作正常,直到我join这部分:

  nodejs.ssh.username = 'docker' nodejs.ssh.password = 'tcuser' nodejs.vm.provider :docker do |docker| docker.force_host_vm = true docker.has_ssh = true docker.image = 'ubuntu' docker.remains_running = false end 

身份validation不起作用,我有义务在每个文件同步时手动input密码! (这不是真正的问题)

这就是问题:

 $ vagrant up nodejs --provider docker Bringing machine 'nodejs' up with 'docker' provider... ==> nodejs: Docker host is required. One will be created if necessary... nodejs: Docker host VM is already ready. ==> nodejs: Syncing folders to the host VM... nodejs: The machine you're rsyncing folders to is configured to use nodejs: password-based authentication. Vagrant can't script rsync to automatically nodejs: enter this password, so you'll likely be prompted for a password nodejs: shortly. nodejs: nodejs: If you don't want to have to do this, please enable automatic nodejs: key insertion using `config.ssh.insert_key`. nodejs: Rsyncing folder: /home/admin/vagrant_boxes/apiv2/salt/roots/ => /var/lib/docker/docker_1442333472_30184 docker@127.0.0.1's password: nodejs: Rsyncing folder: /home/admin/vagrant_boxes/apiv2/salt/minion.d/ => /var/lib/docker/docker_1442333472_90011 docker@127.0.0.1's password: nodejs: Rsyncing folder: /home/admin/vagrant_boxes/apiv2/salt/formulas/ => /var/lib/docker/docker_1442333472_52013 docker@127.0.0.1's password: nodejs: Rsyncing folder: /home/admin/vagrant_boxes/apiv2/ => /var/lib/docker/docker_1442333472_20273 docker@127.0.0.1's password: ==> nodejs: Warning: When using a remote Docker host, forwarded ports will NOT be ==> nodejs: immediately available on your machine. They will still be forwarded on ==> nodejs: the remote machine, however, so if you have a way to access the remote ==> nodejs: machine, then you should be able to access those ports there. This is ==> nodejs: not an error, it is only an informational message. ==> nodejs: Creating the container... nodejs: Name: apiv2_nodejs_1442333483 nodejs: Image: ubuntu nodejs: Volume: /var/lib/docker/docker_1442333472_30184:/srv/salt nodejs: Volume: /var/lib/docker/docker_1442333472_90011:/etc/salt/minion.d nodejs: Volume: /var/lib/docker/docker_1442333472_52013:/srv/formulas nodejs: Volume: /var/lib/docker/docker_1442333472_20273:/vagrant nodejs: Port: 8001:80 nodejs: Port: 8002:3600 nodejs: Port: 127.0.0.1:2222:22 nodejs: nodejs: Container created: 032bddad87adc9cb ==> nodejs: Starting container... ==> nodejs: Waiting for machine to boot. This may take a few minutes... 

好像我会等待永恒!

有什么build议么 ?

更新

这是debugging的输出:

  INFO ssh: SSH is ready! DEBUG ssh: Exit status: 0 DEBUG ssh: Re-using SSH connection. INFO ssh: Execute: (sudo=false) DEBUG ssh: Exit status: 0 DEBUG ssh: Re-using SSH connection. INFO ssh: Execute: echo -n "========== VAGRANT DOCKER BEGIN =========="; "docker" "ps" "-a" "-q" "--no-trunc" (sudo=false) DEBUG ssh: Re-using SSH connection. INFO ssh: Execute: echo -n "========== VAGRANT DOCKER BEGIN =========="; "docker" "ps" "-a" "-q" "--no-trunc" (sudo=false) DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive... DEBUG ssh: Sending SSH keep-alive.. 

所以你这样做:

 docker.has_ssh = true 

但是你的docker镜像没有sshd:

 docker.image = 'ubuntu' 

你可以用这样的东西来validation:

 ~$ docker run -ti ubuntu /bin/bash user@4baf7c72d5a8:/# sshd bash: sshd: command not found user@4baf7c72d5a8:/# 

你必须创build一个具有sshd或者使用已经安装了sshd的Dockerfile创build的。

另外,一旦你看到上面的问题。 跑:

 docker ps 

确保您的容器正在运行。 如果不是,那么检查你的/var/log/docker.log文件