Vagrant运行Docker的几种方法
Vagrant的docker provisioner能够自动安装Docker、下载Docker容器、随着vagrant up命令自动运行容器。 Vagrantfile Vagrant.configure("2") do |config| config.vm.provision "docker" do |d| d.pull_images "consul" d.run "consul" d.pull_images "rabbitmq" d.run "rabbitmq" end end 仅使用Vagrant的docker provisioner安装Docker,使用脚本下载并运行Docker容器 Vagrantfile # Install Docker config.vm.provision "docker" # Download Docker images, create and start containers config.vm.provision :shell, :path => "runMyDockers.sh" runMyDockers.sh #!/bin/bash docker rm -f consul 2>/dev/null docker create --hostname consul --name consul -v /data/consul1:/data --dns 127.0.0.1 --restart always -p 8500:8500 --env CONSUL_OPTIONS=-bootstrap consul:dev docker start consul docker rm -f rabbitmq 2>/dev/null docker create --name rabbitmq --hostname rabbitmq -p 5672:5672 -v /data/rabbitmq:/data --dns 127.