Setting volumes in docker-compose within Vagrant

时间:2018-08-22 13:58:48

标签: docker docker-compose vagrant

I'm trying to make use of the built-in docker-compose provider support in Vagrant (not the provisioner or the extension here: https://github.com/leighmcculloch/vagrant-docker-compose)

As I understand it the vagrant provider configuration is merged with the compose_configuration to generate the docker-compose.yml, which is then executed by docker-compose.

But it seems like some features in docker-compose cannot be specified in the vagrant configuration, for example named volumes. If I have this:

config.vm.provider "docker" do |d|
  d.build_dir = "." 
  d.has_ssh = true
  d.compose = true
  d.volumes = ["~/web:/web-host"]
  d.compose_configuration = {
      "version" => '2', 
      "services" => {
            "default" => {
                "volumes" => [
                  "dragonfly:~/public/dragonfly" ]
             }
      }
  }

}

I would expect vagrant to merge the two volumes, but instead it just seems to overwrite the compose_configuration one in the generated docker-compose.yml so I end up with:

default:
  volumes:
    - "~/web:/vagrant"

I've no idea where the /vagrant path is coming from.

And docker named volumes cannot be set in the main vagrant config as they are not supported.

So where should I be setting the volumes so they are carried through into docker-compose ?

0 个答案:

没有答案