A Vagrant provisioner for Docker Compose. Installs Docker Compose and can also bring up the containers defined by a docker-compose.yml.
vagrant plugin install vagrant-docker-composeVagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provision :docker
config.vm.provision :docker_compose
endVagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provision :docker
config.vm.provision :docker_compose, yml: "/vagrant/docker-compose.yml", run: "always"
endEquivalent to running:
docker-compose -f [yml] up -dVagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provision :docker
config.vm.provision :docker_compose,
yml: [
"/vagrant/docker-compose-base.yml",
"/vagrant/docker-compose.yml",
...
],
run: "always"
endEquivalent to running:
docker-compose -f [yml-0] -f [yml-1] ... up -dVagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provision :docker
config.vm.provision :docker_compose, yml: "/vagrant/docker-compose.yml", rebuild: true, run: "always"
endEquivalent to running:
docker-compose -f [yml] rm --force
docker-compose -f [yml] build
docker-compose -f [yml] up -dVagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provision :docker
config.vm.provision :docker_compose, yml: "/vagrant/docker-compose.yml", rebuild: true,
options: "--x-networking", command_options: { rm: "", up: "-d --timeout 20"}, run: "always"
endEquivalent to running:
docker-compose --x-networking -f [yml] rm
docker-compose --x-networking -f [yml] build
docker-compose --x-networking -f [yml] up -d --timeout 20yml– one or more Compose files (YAML), may be aStringfor a single file, orArrayfor multiple.compose_version– defaults to1.24.1.project_name– compose will default to naming the projectvagrant.env– aHashof environment variables to value that are passed to thedocker-composecommands, defaults to an emptyHash.executable_symlink_path– the location the executable will be symlinked to, defaults to/usr/local/bin/docker-compose.executable_install_path– the location the executable will be stored, defaults to<executable_symlink_path>-<compose_version>, i.e./usr/local/bin/docker-compose-1.5.0.options- aStringthat's included as the first arguments when calling the docker-compose executable, you can use this to pass arbitrary options/flags to docker-compose, default tonil.command_options- aHashof docker-compose commands to options, you can use this to pass arbitrary options/flags to the docker-compose commands, defaults to:{ rm: "--force", up: "-d" }.
See example in the repository for a full working example.