容器作为windows / vagrant env中的卷模式

时间:2014-10-07 19:54:51

标签: windows vagrant docker

我试图在我的本地windows + vagrant + docker环境中为持久存储实现this模式。

Vagrant.configure("2") do |config|
    config.vm.network :forwarded_port,
    guest: 5000, host: 5000
    config.vm.define "db" do |a|
        a.vm.provider "docker" do |d|
            d.build_dir = "./worker"
            d.remains_running = false
        end
    end
    config.vm.define "app" do |a|
        a.vm.provider "docker" do |d|
            d.build_dir = "."
            d.create_args = ["--volumes-from=db"]
        end
    end
end

运行

vagrant up db --provider=docker

不会造成麻烦。然后

vagrant up app --provider=docker

导致以下投诉

Stderr: 2014/10/07 19:50:07 Error: Cannot start container a999e636639be959ce4a39
9755133f24f0e6565cf526fd8bdd9135b522cbe1fd: Container db not found. Impossible t
o mount its volumes

直观地说,两个虚拟机无法相互通信是有道理的,但我无法找到在一个虚拟机中运行多个容器的方法。有办法吗?

1 个答案:

答案 0 :(得分:0)

您必须为db的容器定义一个名称,并告诉vagrant以定义的顺序引导容器。

Vagrant.configure("2") do |config|
    config.vm.network :forwarded_port,
    guest: 5000, host: 5000
    config.vm.define "db" do |a|
        a.vm.provider "docker" do |d|
            d.name = "db
            d.build_dir = "./worker"
            d.remains_running = false
        end
    end
    config.vm.define "app" do |a|
        a.vm.provider "docker" do |d|
            d.build_dir = "."
            d.create_args = ["--volumes-from=db"]
        end
    end
end

然后运行

vagrant up --no-parallel