我正在使用Saltstack / Shell来配置一个流浪汉机器,但现在我想将Docker添加为提供者。我有一个超时问题,所以我修改了超时值。现在看来机器永远不会起作用:我一直在等待,没有任何反应!
这是我的Vagrant文件:
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一切正常,直到我添加了这部分:
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
身份验证无效,我不得不在每个文件同步时手动输入密码! (这不是真正的问题)
这是问题所在:
$ 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...
好像我会等待永恒!
有什么建议吗?
更新:
这是debug的输出:
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..
答案 0 :(得分:0)
所以你这样做:
docker.has_ssh = true
但你的码头图片没有sshd:
docker.image = 'ubuntu'
您可以使用以下内容进行验证:
~$ docker run -ti ubuntu /bin/bash
user@4baf7c72d5a8:/# sshd
bash: sshd: command not found
user@4baf7c72d5a8:/#
您必须创建一个具有sshd或使用已使用安装了sshd的Dockerfile创建的sshd。
一旦你看到上面的问题。运行:
docker ps
确保您的容器正在运行。如果不是,请检查您的/var/log/docker.log
文件