gpt4 book ai didi

docker - Docker作为Vagrant的提供商

转载 作者:行者123 更新时间:2023-12-02 18:42:57 24 4
gpt4 key购买 nike

我正在使用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...

看来我会等待永恒!

有什么建议么 ?

更新:

这是调试的输出:
 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'

您可以通过以下方式进行验证:
~$ docker run -ti ubuntu /bin/bash
user@4baf7c72d5a8:/# sshd
bash: sshd: command not found
user@4baf7c72d5a8:/#

您必须创建一个具有sshd的应用程序,或使用通过安装了sshd的Dockerfile创建的应用程序。

同样,一旦您看到上面的问题。跑:
docker ps

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

关于docker - Docker作为Vagrant的提供商,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32591191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com