How to access different boot2docker instance in a virtual box - vagrant

I created two boot2docker instances in virtual box:
"boot2docker-vm" {8674bb87-b7ba-4179-9a09-c779611b1d9a}
"boot2docker-work" {53ffd6d6-2fc4-4c4f-b34e-c2f8dd87dd40}
They use different boot2docker.iso and different profiles.
The first vm is default, so if you run 'docker images' outside the virtual machine, it will use the first one by default.
But how can I access the second boot2docker "boot2docker-work", I know 'boot2docker ssh' works, but I want to run docker command outside the virtual machine.
I tried to set DOCKER_HOST and ca, cert for the second vm, but has the following errors:
An error occurred trying to connect: Get https://192.168.59.110:2376/v1.19/containers/json: dial tcp 192.168.59.110:2376: i/o timeout
Any ideas?

Ok,I find a solution.
when we create a VM, it will connect to a vboxnet with IP, if the ip is 192.168.59.103, it will add 192.168.59 to routing table
192.168.58 link#10 UC 3 0 vboxnet
then if we start the vm, 192.168.58.103 will be added to the routing table with right gateway:
192.168.58.103 8:0:27:1e:d1:24 UHLWI 0 3120 vboxnet 210
But if we create another vm with ip 192.168.58.104, then it will not have a right gateway:
192.168.58.104 link#10 UC 3 0 vboxnet
This makes the vm not working.
So my solution is that, use 192.168.59, or 192.168.60, then all problems gone.
But can anyone explain the routing mechanism of this?

Related

Unable to contact the remote controller at 192.168.56.3

Good morning,
I want to set up OpenDayLight SDN Controller and Mininet in VirtualBox. So far I installed both and got them running.
My interfaces are:
1 NAT
1 Host Only Adapter
for both the VMs.
The Host only adapter has an IP address of 192.168.56.1.
OpenDayLight VM receives 192.168.56.3,
Mininet VM receives 192.168.56.4.
I am able to ping the two VMs. What I can't do is creating a simple test topology with the command:
sudo mn --topo linear,3 --mac --controller=remote,ip=192.168.56.3,port=6633 --switch ovs,protocols=OpenFlow13
In fact, running it causes this error:
mininet#mininet-vm:~$ sudo mn --topo linear,3 --mac --controller=remote,ip=192.168.56.3,port=6633 --switch ovs,protocols=OpenFlow13
*** Creating network
*** Adding controller
Unable to contact the remote controller at 192.168.56.3:6633
*** Adding hosts:
h1 h2 h3
*** Adding switches:
s1 s2 s3
*** Adding links:
(h1, s1) (h2, s2) (h3, s3) (s2, s1) (s3, s2)
*** Configuring hosts
h1 h2 h3
*** Starting controller
c0
*** Starting 3 switches
s1 s2 s3 ...
*** Starting CLI:
mininet>
From the main site:
Important troubleshooting - if you are running VirtualBox on the same
host/desktop where the controller is running, and trying to start the
virtual network on Mininet VM produces this error: "Unable to contact
the remote controller at ...", then the following resolves the
problem:
In VirtualBox, go to File-Preferences-Network and make sure you have
at least one interface defined as Host-Only. Lets say its name is
vboxnet0
In VirtualBox - Mininet Vm - Settings - Network, check that the
adapter is of type Host only , and is connected to the interface from
item 1 (vboxnet0)
On your host where controller and VirtualBox run, do "ifconfig"
command to display all network interfaces on the machine.
Search for the interface as in item 1 (vboxnet0 in our example) Take
the ip address specified there (most probably 192.168.56.1 - default),
and that is the correct remote controller ip address to use when
starting a virtual network in mininet vm as stated in the example
above (--controller=remote,ip=192.168.56.1) .
If you are still not able to connect, you might want to consider
temporarily disabling firewall on the host running the controller (on
Linux, for example, iptables -F will do the job)
Sometimes, the way you start the mininet is a problem, it does not
give error, but does not connect to the remote server. Here is a wrong
example:
sudo mn --topo=tree,3 --mac --switch=ovsk --controller=remote,
ip=192.168.16.10
Here is the correct example:
sudo mn --topo=tree,3 --mac --switch=ovsk
--controller=remote,ip=192.168.16.10
The difference is the "SPACE" between "remote," and "ip".
I don't see what I miss.
Thank you in advance,
Davide
I finally managed to fix that.
sudo ufw disable both on mininet and ODL solved the issue.
Thanks again jamo for the hint.
do you have the openflowplugin features running on ODL? you can check from
the karaf console with "feature:list -i | grep openflow"
you can also see if port 6633 is running on the ODL VM. something like "netstat -na | grep 6633"
see if you can open a connection from your mininet VM to the ODL IP and openflow
port. I think it would be "nc 192.168.56.3 6633"
just a few ideas to troubleshoot, but since you can ping the ODL ip from your
mininet VM, I'm guessing there is something wrong with connecting to the openflow
port. so maybe it's not even open (feature not loaded, or blocked, etc)

Why can't I connect to 127.0.0.1 HortonWorks Dashboard?

I have installed Virtual Box (Version 5.2.0 r118431 (Qt5.6.2)) on Windows 10 and i imported appliance HDP_2.4_virtualbox_v3 (downloaded from here).
I followed the tutorial from here step by step.
The virtual machine is running on the computer from where I am trying to access the Dashboard. I have set up the Host Only Adapter Option on the sandbox so the computer and the virtual machine can communicate
After the CentOs finished booting I am prompt to enter to the ip 127.0.0.1:8888, which is a different address from the tutorial,
and there is no server listening to that address because i get
"127.0.0.1 refused to connect." in the browser.
image here
Run the ipconfig command in your command prompt and identyfy your virtual box's ip under Ethernet adapter VirtualBox Host-Only Network.
Take that ip address and go to your Virtual Box.
Select your appliance and go to Settings->Network->Adapter 1->Port Forwarding.
Replace the Host IP 127.0.0.1 for the port you need 8080, 8888 and so on with the ip of your virtual box that should be sth like 192.168.x.x.
Now start your sandbox, login on it and try to connect in your browser to the new ip set 192.168.x.x:8888.
Use appliance HDP_2.4_virtualbox because in the most recent some linux commands like netstat are considered deprecated and no longer function, which willmake your life harder when trying to debug or identify a networking problem.
If you still encounter issues eith it, reinstall your operating system, reinstall your virtual box and reimport the sandbox, make the changes needed in the Port Forwarding settings and it should be ok.
try to connect using 127.0.0.1 to connect make sure the VM is running make sure there are no errors if there are debug them and at the last straw uninstall the Vm and retry (make sure to make a backup if there are any files)
you can also try to check all the local host ips on your network and try to connect to them
Make sure you set NAT in your VirtualBox network settings:

How to bind the VM docker-machine creates to OSX IP address?

I'm developing locally with Docker on OSX using the latest Docker toolkit. I have a node server running in a docker container, bound to port 9999 of the VM. I can hit this server from a browser on my mac, and I would like to hit from another device on the same network. Is there a way to bind the VM to the machine's IP address? Or otherwise expose it?
I just figured this one out today! I am using docker-machine with virtualbox on Mac OS 10.10.5. The first thing I tried was to change the network interface from NAT to Bridged. This just breaks docker-machine's ability to communicate with the VM.
Instead I ADDED another network adapter running in bridged mode.
After starting the docker-machine I get this:
$ docker-machine ip redis-test
10.222.11.242
That is a local network address accessible from anyone else in my office or on my VPN.
Then if I run something like:
$ docker run -p 6379:6379 -d redis
I get a containerized redis service running on port 6379 of the 10.222.11.242 address.
So I can do this from anywhere else on the network:
$ telnet 10.222.11.242 6379
Trying 10.222.11.242...
Connected to 10.222.11.242.
Escape character is '^]'.
info
$1827
# Server
redis_version:2.8.19
...
And as a cool bonus of this we can remap the ports like this:
$ docker run -p 8080:6379 -d redis
e7cc53d9c157a658041c3bee5967dd3678b4d35e6146a02220a87bfebfc919ad
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e7cc53d9c157 redis "/entrypoint.sh redis" 7 seconds ago Up 6 seconds 0.0.0.0:8080->6379/tcp goofy_yonath
bf1dc6c7c6b5 redis "/entrypoint.sh redis" 51 minutes ago Up 51 minutes 0.0.0.0:6379->6379/tcp redis
Now I have two redis instances listening on different ports (6379 and 8080) of the same IP.
EDIT: Here are some details to help those confused about adding a NIC to the VM in VirtualBox. I have only used VirtualBox for this and cannot advise about other virtualization system configurations.
Stop the VM by selecting it in the VM Manager and using the right-click menu or pressing 'command-F'.
Click "Settings".
Click "Network".
Select one of the Adapters that is not currently enabled.
Enable it.
Select "Bridged Adapter" in the "Attached to" selection.
Click OK.
Start your VM and try it out.
NOTE: I am sure there are some clever command line options for doing this setup, but since I only ever needed to set it once I have never bothered to automate it.
You could setup port forwarding on the VirtualBox NAT adaptor.
Bridging it to the local network (in the answer above) is not the same as using the OSX IP address. Bridging can sometimes cause extra headaches if you are on laptop and move to different internet connections. The VM may not automatically pull a new IP from the new network, etc.
In the UI go to Settings --> Network --> Port Forwarding or from the commandline something like this:
VBoxManage controlvm "default" natpf1 "tcp-port9999,tcp,,9999,,9999";
where "default" is the name of the VM ("default" is normally used for docker-machine) and 9999 is the port you want to map.
More info at: https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md
https://www.virtualbox.org/manual/ch06.html (Configuring Port forwarding with NAT)
Did you put the expose command in Dockerfile?
EXPOSE 9999
Based on #e.thompsy answer, here is the command line version.
First, figure out the interface name you need using:
vboxmanage list bridgedifs
For me it was en1.
Then:
docker-machine create ...
docker-machine stop $VM
vboxmanage modifyvm "$VM" --nic3 bridged --bridgeadapter3 en1
docker-machine start $VM

How to use Putty to connect to a virtual machine?

I am running a virtual machine on Virtual Box
On running ifconfig eth1, I get
inet addr: 192.168.56.11 and many more values.
How do I use Putty (ssh) here?
I entered 192.168.56.11 on the Host Name and 80 on the Port Number, but Putty can't connect.
I am trying to follow the guidelines from this course:
https://s3-us-west-2.amazonaws.com/cs144-misc/instructions/vm.html
What exactly does Putty do? I don't understand why I need to do this.
PuTTY will open a "network" between both machines. You'll get a console (like the shell) when you'll be connected. Really useful to administrate remote server from your computer.
Usually, the port is not 80, but 22.
For oracle vm virtual box:
1)Power of your machine
2)goto Settings -> Network -> Adapter1 -> Enable Network Adapter -> select "Bridge Adapter" in Attache To tab and click 'ok" button
3) open terminal in virtual box and type" ifconfig"
in first paragraph
eth0 Link encap:Ethernet HWaddr 08:00:27:fb:d1:28
inet addr:172.16.2.199
4) Here ip address is "172.16.2.199" using this ip and port 22 ,you can login through putty and winscp also
Try opening terminal through VMWare's console on Ubuntu and then run below given code:
sudo apt-get install openssh-server
I had faced the same issue.
Note: I assume you have already started the VM, importing the ISO image, and tried to access the machine with 10.X.X.X or 172.X.X.X range IP address from the Putty agent and got an time-out message.
Before making any changes to the network configuration on the VM or trying bridge-adapters, as suggested by many of the articles online, I suggest you to check 2 robust points which forms the bus for your VM on VirtualBox and Putty agent installed on your system.
1st Point:
Opening Host Network Manager in File section of your Oracle VirtualBox
Adding a host-only ethernet network (I suggest to keep a 192.X.X.X range)
2nd Point: Adding a host-only adapter, under the network settings of your VM.
Host-Only Adapter settings
If you follow these steps before booting up the VM for the first time, your VM will be allocated with a 192 range IP address (by the dhcp) the moment it boots up and starts running. Now all you need to do is, install and openssh-server and use the 192-range IP address with the Putty agent and Voila!!
Hope this help! Greetings!

Using gitlab-vagrant-vm from OSX host

I followed the instructions here and was able to succesfully (I think) install the gitlab vagrant virtual machine on OSX 10.8 using virtualbox.
I can do vagrant up to get the VM running, and everything seems to work fine. After that I can do vagrant ssh without a problem. Also, after sshing into the VM I was able to do bundle exec rake gitlab:test, which completed with results being 1584 examples, 0 failures.
I would like to see the gitlab web interface from my OSX host machine. I thought I could just direct my browser to the IP indicated in the VagrantFile (http://192.168.3.14), but that didn't work.
Any ideas?
Also any other usage tips for this setup would be appriciated (things like where the repositories are stored on my host machine so I can back them up, if anyone set the gitlab-vagrant-vm up for external access from either another computer on the network or a remote source, ect.)
You have to connect a second interface for vagrant. To do this you've to edit the VagrantFile.
For example if you want to conenct to the host wifi add the following line after 192.168.3.14
config.vm.network :bridged, bridge: "en0: Wi-Fi (AirPort)"
You also can bridge to the ethernet interface. Use ifconfig on the host machine to determine the right interface. After that the dyndns-server of the host network will assign an IP to the Vagrant-Box. Then you can access GitLab on that IP.
Did you actually start the server? You can do that with
bundle exec foreman start -p 3000
This will start the server on port 3000, you would then access it from the host with
http://192.168.3.14:3000/
Hope this helps,
Chris

Resources