使用vagrant啓動虛擬機
mkdir base && cd base
cat >Vagrantfile<<EOF
Vagrant.configure("2") do |config|
config.vm.box = "centos-7.4-docker-17"
config.ssh.insert_key = false
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--name", "will"]
end
config.vm.synced_folder ".", "/vagrant", disabled: true
end
EOF
vagrant up
複製代碼
登陸配置安裝相關軟件
rm -f /etc/udev/rules.d/70-persistent-net.rules
yum clean all
apt-get clean
rm -rf /tmp/*
rm -f /var/log/wtmp /var/log/btmp
history -c
> .bash_history
sudo su - vagrant
history -c
> .bash_history
vagrant halt
複製代碼
製做基礎box
cat >Vagrantfile.base<<EOF
Vagrant.configure(2) do |config|
config.vm.synced_folder ".", "/vagrant", disabled: true
end
EOF
vagrant package --base will --vagrantfile Vagrantfile.base --output will-base.box
複製代碼
測試
vagrant box add base will-base.box
vagrant init base
vagrant up
vagrant ssh-config
vagrant ssh
複製代碼
參考文檔
- https://thornelabs.net/2013/11/11/create-a-centos-6-vagrant-base-box-from-scratch-using-virtualbox.html
- https://www.dravetech.com/blog/2016/01/14/vagrant_box_ios_xr.html
- http://blog.pangyanhan.com/posts/2015-11-10-creating-a-vagrant-base-box.html