Provisioning a VM with your Vagrantfile
.
e.g. to install docker
create a file bootstrap.sh
:
It’s a little convoluted. Why didn’t I use config.vm.provision "docker"
? ‘cos it didn’t work for me: https://stackoverflow.com/questions/52498892/install-docker-via-a-vagrantfile
1 2 3 4 |
#!/usr/bin/env bash apt-get update apt-get install -y docker-ce |
Note: don’t use apt-get install -y docker
as this installs the System tray!
https://gist.github.com/kjellski/6158747 and https://unix.stackexchange.com/questions/363048/unable-to-locate-package-docker-ce-on-a-64bit-ubuntu/363058#363058
and add it to your Vagrantfile
, e.g.:
1 2 3 4 5 6 |
Vagrant.configure('2') do |config| config.vm.box = "hashicorp/precise64" config.vm.define "vm2" config.vm.hostname = "vm2" config.vm.provision :shell, path: "bootstrap.sh" end |
and force Vagrant to reprovision with:
vagrant reload --provision
https://www.vagrantup.com/intro/getting-started/provisioning.html
https://www.vagrantup.com/docs/vagrantfile/machine_settings.html