How can I start the provisioning of Docker via an external Dockerfile
? My Vagrantfile
looks like this at the moment:
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.define :server_infrastructure do |t|
end
config.vm.provision "docker" do |d|
d.pull_images "ubuntu"
#how does the below work?
#d.build "new-container-name" "local-docker-file-name"
end
end
Your help is greatly appreciated
An option for the Docker provisioner to build images was added in v1.6.0. Download the latest version from the Vagrant website.
Once you've done that, put a Dockerfile
next to your Vagrantfile
. Add this to your Vagrantfile
:
config.vm.provision "docker" do |d|
d.build_image "/vagrant", args: "-t my-name/my-new-image"
d.run "my-name/my-new-image"
end
Now your Docker image will be built and run with vagrant up
.