-
-
Save anzz1/1c05e4d273ad783d07d6f30ec134e1ea to your computer and use it in GitHub Desktop.
# boot2docker v18.01.0-ce 03596f5 Linux 4.4.111-boot2docker x86_64 | |
## config | |
BOX_CPU_COUNT = "2" | |
BOX_RAM_MB = "4096" | |
DOCKER_IMAGE = "anzz1/miyoomini-toolchain:latest" | |
DOCKER_RUN = "/bin/bash" | |
Vagrant.configure("2") do |config| | |
config.vagrant.plugins = ["vagrant-vbguest", "vagrant-reload"] | |
if Vagrant.has_plugin?("vagrant-vbguest") then | |
config.vbguest.auto_update = false | |
end | |
config.vm.box = "anzz1/boot2docker" | |
config.vm.box_version = "18.01.0" | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--ioapic", "on"] | |
vb.customize ["modifyvm", :id, "--memory", BOX_RAM_MB] | |
vb.customize ["modifyvm", :id, "--cpus", BOX_CPU_COUNT] | |
end | |
config.vm.synced_folder ".", "/vagrant", type: "virtualbox" | |
config.vm.provision "shell", inline: <<-SHELL | |
sed -in 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /usr/local/etc/ssh/sshd_config | |
sed -in 's/^#PermitEmptyPasswords no/PermitEmptyPasswords yes/g' /usr/local/etc/ssh/sshd_config | |
sed -in 's/^#PrintMotd yes/PrintMotd no/g' /usr/local/etc/ssh/sshd_config | |
echo '#!/bin/bash' > /var/lib/boot2docker/bootlocal.sh | |
echo 'passwd -d docker' >> /var/lib/boot2docker/bootlocal.sh | |
echo 'passwd -d root' >> /var/lib/boot2docker/bootlocal.sh | |
echo 'echo "cd /vagrant" >> /home/docker/.ashrc' >> /var/lib/boot2docker/bootlocal.sh | |
echo 'echo "docker run -it --rm -v /vagrant/workspace:/root/workspace #{DOCKER_IMAGE} #{DOCKER_RUN}" >> /home/docker/.ashrc' >> /var/lib/boot2docker/bootlocal.sh | |
echo 'echo "exit" >> /home/docker/.ashrc' >> /var/lib/boot2docker/bootlocal.sh | |
SHELL | |
if Vagrant.has_plugin?("vagrant-reload") then | |
config.vm.provision :reload | |
end | |
config.vm.provision "docker", | |
images: [ DOCKER_IMAGE ] | |
config.vm.provision "shell", inline: <<-SHELL | |
echo '==============================' | |
echo 'CPU Count : #{BOX_CPU_COUNT}' | |
echo 'RAM MB : #{BOX_RAM_MB}' | |
echo 'Docker Image : "#{DOCKER_IMAGE}"' | |
echo 'Docker Run Command : "#{DOCKER_RUN}"' | |
echo '------------------------------' | |
echo 'Vagrant box provisioned !' | |
echo '"vagrant ssh" to connect or via ssh@localhost:2222 (user: docker, pass: empty)' | |
echo '"vagrant halt" to shut down' | |
echo '"vagrant up" to power up' | |
echo '"vagrant destroy" to clean up and destroy' | |
SHELL | |
end |
# Debian 10 ("Buster") v10.20211018.1 Linux 4.9.208-1 x86_64 | |
Vagrant.configure("2") do |config| | |
config.vagrant.plugins = ["vagrant-vbguest"] | |
if Vagrant.has_plugin?("vagrant-vbguest") then | |
config.vbguest.auto_update = false | |
end | |
config.vm.box = "debian/contrib-buster64" | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--ioapic", "on"] | |
vb.customize ["modifyvm", :id, "--memory", "4096"] | |
vb.customize ["modifyvm", :id, "--cpus", "2"] | |
end | |
config.vm.synced_folder ".", "/vagrant", type: "virtualbox" | |
config.vm.network "forwarded_port", guest: 80, host: 8080 | |
config.vm.provision "shell", inline: <<-SHELL | |
echo -e "1234\n1234" | passwd root | |
grep -c "cd /vagrant" /home/vagrant/.bashrc || echo -e "\ncd /vagrant" >> /home/vagrant/.bashrc | |
cp /home/vagrant/.bashrc /root/.bashrc | |
sed -in 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config | |
sed -in 's/^PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config | |
sed -in 's/^X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config | |
sed -in 's@deb.debian.org/debian buster main@deb.debian.org/debian buster main contrib non-free@g' /etc/apt/sources.list | |
sed -in 's@security.debian.org/debian-security buster/updates main@security.debian.org/debian-security buster/updates main contrib non-free@g' /etc/apt/sources.list | |
sed -in 's@deb.debian.org/debian buster-updates main@deb.debian.org/debian buster-updates main contrib non-free@g' /etc/apt/sources.list | |
sed -in 's@deb.debian.org/debian buster-backports main@deb.debian.org/debian buster-backports main contrib non-free@g' /etc/apt/sources.list | |
apt-get -y -qq update | |
apt-get -y -qq -f purge apparmor | |
apt-mark hold apparmor | |
rm -rf /var/cache/apparmor | |
rm -rf /etc/apparmor.d | |
apt-get -y -qq install build-essential git unzip | |
git config --system --add safe.directory '*' | |
git config --system --add user.useConfigOnly true | |
mkdir -p /etc/vim/colors | |
test -f "/etc/vim/colors/less.vim" || wget -q -O "/etc/vim/colors/less.vim" "https://raw.githubusercontent.com/vim-scripts/less.vim/master/colors/less.vim" | |
test -d "/usr/share/vim/vim81/colors" && ln -s "/etc/vim/colors/less.vim" "/usr/share/vim/vim81/colors/less.vim" | |
echo 'color less' > /etc/vim/vimrc.local | |
echo 'set mouse-=a' >> /etc/vim/vimrc.local | |
/etc/init.d/ssh restart | |
SHELL | |
end |
# Debian 11 ("Bullseye") v11.20230602.1 Linux 5.10.178-3 x86_64 | |
Vagrant.configure("2") do |config| | |
config.vagrant.plugins = ["vagrant-vbguest", "vagrant-docker-compose"] | |
if Vagrant.has_plugin?("vagrant-vbguest") then | |
config.vbguest.auto_update = false | |
end | |
config.vm.box = "debian/bullseye64" | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--ioapic", "on"] | |
vb.customize ["modifyvm", :id, "--memory", "4096"] | |
vb.customize ["modifyvm", :id, "--cpus", "2"] | |
end | |
config.vm.synced_folder ".", "/vagrant", type: "virtualbox" | |
config.vm.network "forwarded_port", guest: 80, host: 8080 | |
config.vm.provision :docker | |
if Vagrant.has_plugin?("vagrant-docker-compose") then | |
config.vm.provision :docker_compose | |
end | |
config.vm.provision "shell", inline: <<-SHELL | |
echo -e "1234\n1234" | passwd root | |
grep -c "cd /vagrant" /home/vagrant/.bashrc || echo -e "\ncd /vagrant" >> /home/vagrant/.bashrc | |
cp /home/vagrant/.bashrc /root/.bashrc | |
sed -in 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config | |
sed -in 's/^PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config | |
sed -in 's/^X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config | |
apt-get -y -qq update | |
apt-get -y -qq -f purge apparmor | |
apt-mark hold apparmor | |
rm -rf /var/cache/apparmor | |
rm -rf /etc/apparmor.d | |
apt-get -y -qq install vim | |
git config --system --add safe.directory '*' | |
git config --system --add user.useConfigOnly true | |
mkdir -p /etc/vim/colors | |
test -f "/etc/vim/colors/less.vim" || wget -q -O "/etc/vim/colors/less.vim" "https://raw.githubusercontent.com/vim-scripts/less.vim/master/colors/less.vim" | |
echo "color less" > /etc/vim/vimrc.local | |
echo "set mouse-=a" >> /etc/vim/vimrc.local | |
service ssh restart | |
SHELL | |
end |
# Debian 7 ("Wheezy") v7.11 Linux 3.2.81-1 x86_64 | |
Vagrant.configure("2") do |config| | |
config.vagrant.plugins = ["vagrant-vbguest"] | |
if Vagrant.has_plugin?("vagrant-vbguest") then | |
config.vbguest.auto_update = false | |
end | |
config.vm.box = "UNL-DIPT/wheezy64" | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--ioapic", "on"] | |
vb.customize ["modifyvm", :id, "--memory", "4096"] | |
vb.customize ["modifyvm", :id, "--cpus", "2"] | |
end | |
config.vm.synced_folder ".", "/vagrant", type: "virtualbox" | |
config.vm.network "forwarded_port", guest: 80, host: 8080 | |
config.vm.provision "shell", inline: <<-SHELL | |
echo -e "1234\n1234" | passwd root | |
grep -c "cd /vagrant" /home/vagrant/.bashrc || echo -e "\ncd /vagrant" >> /home/vagrant/.bashrc | |
cp /home/vagrant/.bashrc /root/.bashrc | |
sed -in 's/^UsePrivilegeSeparation yes/UsePrivilegeSeparation no/g' /etc/ssh/sshd_config | |
sed -in 's/^X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config | |
echo 'deb http://archive.debian.org/debian-security wheezy/updates main contrib non-free' >> /etc/apt/sources.list | |
echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::AllowInsecureRepositories "true";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::AllowDowngradeToInsecureRepositories "true";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::Check-Date "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::Check-Valid-Until "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::https::Verify-Peer "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::https::Verify-Host "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::gpgv::Options "--ignore-time-conflict --no-options --no-default-keyring --no-auto-check-trustdb --trust-model always";' >> /etc/apt/apt.conf.d/98allow_unauth | |
apt-get -y -qq update | |
apt-get -y -qq upgrade | |
apt-get -y -qq install build-essential vim git | |
git config --system --add safe.directory '*' | |
git config --system --add user.useConfigOnly true | |
mkdir -p /etc/vim/colors | |
test -f "/etc/vim/colors/less.vim" || wget -q -O "/etc/vim/colors/less.vim" "https://raw.githubusercontent.com/vim-scripts/less.vim/master/colors/less.vim" | |
echo 'color less' > /etc/vim/vimrc.local | |
echo 'set mouse-=a' >> /etc/vim/vimrc.local | |
/etc/init.d/ssh restart | |
SHELL | |
end |
# Debian 8 ("Jessie") v8.11.1 Linux 3.16.68-1 x86_64 | |
Vagrant.configure("2") do |config| | |
config.vagrant.plugins = ["vagrant-vbguest"] | |
if Vagrant.has_plugin?("vagrant-vbguest") then | |
config.vbguest.auto_update = false | |
end | |
config.vm.box = "debian/contrib-jessie64" | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--ioapic", "on"] | |
vb.customize ["modifyvm", :id, "--memory", "4096"] | |
vb.customize ["modifyvm", :id, "--cpus", "2"] | |
end | |
config.vm.synced_folder ".", "/vagrant", type: "virtualbox" | |
config.vm.network "forwarded_port", guest: 80, host: 8080 | |
config.vm.provision "shell", inline: <<-SHELL | |
echo -e "1234\n1234" | passwd root | |
grep -c "cd /vagrant" /home/vagrant/.bashrc || echo -e "\ncd /vagrant" >> /home/vagrant/.bashrc | |
cp /home/vagrant/.bashrc /root/.bashrc | |
sed -in 's/^UsePrivilegeSeparation yes/UsePrivilegeSeparation no/g' /etc/ssh/sshd_config | |
sed -in 's/^PermitRootLogin without-password/PermitRootLogin yes/g' /etc/ssh/sshd_config | |
sed -in 's/^X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config | |
sed -in 's/^PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config | |
sed -in 's@httpredir.debian.org/debian jessie main contrib@archive.debian.org/debian jessie main contrib non-free@g' /etc/apt/sources.list | |
sed -in 's@security.debian.org/ jessie/updates main contrib@archive.debian.org/debian-security jessie/updates main contrib non-free@g' /etc/apt/sources.list | |
echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::AllowInsecureRepositories "true";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::AllowDowngradeToInsecureRepositories "true";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::Check-Date "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::Check-Valid-Until "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::https::Verify-Peer "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::https::Verify-Host "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::gpgv::Options "--ignore-time-conflict --no-options --no-default-keyring --no-auto-check-trustdb --trust-model always";' >> /etc/apt/apt.conf.d/98allow_unauth | |
apt-get -y -qq update | |
apt-get -y -qq upgrade | |
apt-get -y -qq install vim git | |
git config --system --add safe.directory '*' | |
git config --system --add user.useConfigOnly true | |
mkdir -p /etc/vim/colors | |
test -f "/etc/vim/colors/less.vim" || wget -q -O "/etc/vim/colors/less.vim" "https://raw.githubusercontent.com/vim-scripts/less.vim/master/colors/less.vim" | |
echo 'color less' > /etc/vim/vimrc.local | |
echo 'set mouse-=a' >> /etc/vim/vimrc.local | |
/etc/init.d/ssh restart | |
SHELL | |
end |
# Debian 9 ("Stretch") v9.12.0 Linux 4.9.210-1 x86_64 | |
Vagrant.configure("2") do |config| | |
config.vagrant.plugins = ["vagrant-vbguest"] | |
if Vagrant.has_plugin?("vagrant-vbguest") then | |
config.vbguest.auto_update = false | |
end | |
config.vm.box = "debian/contrib-stretch64" | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--ioapic", "on"] | |
vb.customize ["modifyvm", :id, "--memory", "4096"] | |
vb.customize ["modifyvm", :id, "--cpus", "2"] | |
end | |
config.vm.synced_folder ".", "/vagrant", type: "virtualbox" | |
config.vm.network "forwarded_port", guest: 80, host: 8080 | |
config.vm.provision "shell", inline: <<-SHELL | |
echo -e "1234\n1234" | passwd root | |
grep -c "cd /vagrant" /home/vagrant/.bashrc || echo -e "\ncd /vagrant" >> /home/vagrant/.bashrc | |
cp /home/vagrant/.bashrc /root/.bashrc | |
sed -in 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config | |
sed -in 's/^X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config | |
sed -in 's/^#UsePrivilegeSeparation sandbox/UsePrivilegeSeparation no/g' /etc/ssh/sshd_config | |
sed -in 's/^PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config | |
sed -in 's@deb.debian.org/debian stretch main@archive.debian.org/debian stretch main contrib non-free@g' /etc/apt/sources.list | |
sed -in 's@security.debian.org/debian-security stretch/updates main@archive.debian.org/debian-security stretch/updates main contrib non-free@g' /etc/apt/sources.list | |
echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::AllowInsecureRepositories "true";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::AllowDowngradeToInsecureRepositories "true";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::Check-Date "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::Check-Valid-Until "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::https::Verify-Peer "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::https::Verify-Host "false";' >> /etc/apt/apt.conf.d/98allow_unauth | |
echo 'Acquire::gpgv::Options "--ignore-time-conflict --no-options --no-default-keyring --no-auto-check-trustdb --trust-model always";' >> /etc/apt/apt.conf.d/98allow_unauth | |
apt-get -y -qq update | |
apt-get -y -qq upgrade | |
apt-get -y -qq install vim git | |
git config --system --add safe.directory '*' | |
git config --system --add user.useConfigOnly true | |
mkdir -p /etc/vim/colors | |
test -f "/etc/vim/colors/less.vim" || wget -q -O "/etc/vim/colors/less.vim" "https://raw.githubusercontent.com/vim-scripts/less.vim/master/colors/less.vim" | |
echo 'color less' > /etc/vim/vimrc.local | |
echo 'set mouse-=a' >> /etc/vim/vimrc.local | |
/etc/init.d/ssh restart | |
SHELL | |
end |
# Windows 7 Enterprise x64 | |
# config | |
BOX_CPU_COUNT = "2" # cpu count | |
BOX_RAM_MB = "8192" # RAM in megabytes | |
BOX_HOSTONLY_NET = true # enable host-only network adapter | |
BOX_HOSTONLY_IP = "192.168.56.101" # host-only network adapter ip | |
BOX_USER_NAME = "win7" # admin account name | |
BOX_USER_PASSWORD = "123" # admin account password | |
Vagrant.configure("2") do |config| | |
if Vagrant.has_plugin?("vagrant-vbguest") then | |
config.vbguest.auto_update = false | |
end | |
config.vm.box = "anzz1/win7x64" | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--ioapic", "on"] | |
vb.customize ["modifyvm", :id, "--memory", BOX_RAM_MB] | |
vb.customize ["modifyvm", :id, "--cpus", BOX_CPU_COUNT] | |
end | |
if BOX_HOSTONLY_NET == true | |
config.vm.network "private_network", ip: BOX_HOSTONLY_IP | |
end | |
config.vm.communicator = "winrm" | |
config.winrm.username = BOX_USER_NAME | |
config.winrm.password = BOX_USER_PASSWORD | |
config.vm.post_up_message = <<-HELLO | |
============================== | |
CPU Count : #{BOX_CPU_COUNT} | |
RAM (MB) : #{BOX_RAM_MB} | |
SSH Port : 22 => 2222 | |
Telnet Port : 23 => 2223 | |
WinRM Port : 5985 => 55985 | |
RDP Port : 3389 => 33389 | |
Username : #{config.winrm.username} | |
Password : #{config.winrm.password} | |
Host-Only Adapter | |
Enabled : #{BOX_HOSTONLY_NET} | |
IP : #{BOX_HOSTONLY_IP} | |
------------------------------ | |
Windows 7 Enterprise x64 booted ! | |
HELLO | |
end |
What is the purpose of
boot2docker
from Vagrant? To avoid historicaldocker-machine
app? If so how do you set env vars for Docker instead ofdocker-machine.exe env --shell bash
?
Purpose is to easily boot into a docker image. No need to install docker natively, just virtualbox+vagrant is enough.
Modify the DOCKER_IMAGE
variable to set your image and DOCKER_RUN
to set the command to run. That is the main use case, but you can edit the script to change any variables you want or make it do whatever. By default, when you login as docker
it logs you directly to the container itself while root
logs you in to the boot2docker environment and you can explore that too if you want.
If your question is what is boot2docker , that is found here: https://github.com/boot2docker/boot2docker .
Basically it's fast, light and portable way to launch docker images.
Quick boot into a box is OK.
What about passing a network port from a container to a host? It is something that docker
command is performing internally, hiding complexity from users...
It's a minimal Linux box with a Docker installation, so it can do whatever Docker can including passing network ports or whatever else.
In any case, these here are simply for safe keeping and I do not intend to give technical support for them. Sorry.
What is the purpose of
boot2docker
from Vagrant? To avoid historicaldocker-machine
app? If so how do you set env vars for Docker instead ofdocker-machine.exe env --shell bash
?