Vagrant: Provisioning

Provisioning a VM with your Vagrantfile.

e.g. to install dockercreate 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

#!/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.:

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

Leave a Reply

Your email address will not be published. Required fields are marked *