Created
November 9, 2020 13:19
-
-
Save diegolovison/87bb06e950e6ec0faf95228d709b3343 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Required softwares: | |
* Vagrant | |
* docker-machine | |
* virtualbox | |
Create a file: `Vagrantfile` | |
``` | |
Vagrant.configure("2") do |config| | |
config.vm.box = "ubuntu/bionic64" | |
config.vm.network "private_network", ip: "192.168.33.10" | |
config.vm.provision "shell", inline: <<-SHELL | |
apt-get update | |
SHELL | |
end | |
``` | |
in the terminal type: `vagrant up`. If there is an error. Dont do the mistake to type `vagrant up` again. Type `vagrant destroy` before | |
in the terminal create a the public key from `.vagrant/machines/default/virtualbox/private_key`. the command is: `ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub` | |
Now execute: | |
``` | |
docker-machine create \ | |
--driver "generic" \ | |
--generic-ip-address 192.168.33.10 \ | |
--generic-ssh-user vagrant \ | |
--generic-ssh-key .vagrant/machines/default/virtualbox/private_key \ | |
--generic-ssh-port 22 \ | |
default | |
``` | |
``` | |
eval $(docker-machine env default) | |
sudo route -n add 172.17.0.0/16 $(docker-machine ip default) | |
``` | |
Access the vagrant machine: `vagrant ssh` | |
Edit: `/etc/sysctl.conf` | |
``` | |
net.ipv4.ip_forward = 1 | |
``` | |
In virtualbox, reboot the machine | |
from the terminal: `docker run -d httpd` and then `curl 172.17.0.2` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment