Access Docker container running on OS X via boot2docker in Windows virtual machine - macos

Overview:
Host: Mac OS X running boot2docker and Docker
Guest: Windows 7
The Problem:
For my web-development I have set up a docker container via boot2docker on OS X. Within OS X I can access my docker services via boot2docker.
Running boot2docker ip, I get:
The VM's Host only interface IP address is: 192.168.59.103
I am running a Django application on port 1234 (I have mapped the port 5000 on the docker image to port 1234 on my Mac) which I can access within OS X in an web-browser via the address 192.168.59.103:1234. Everything works fine in OS X.
Now I have to test the Web stuff on IE which is why I have downloaded IE8, IE10 and so forth via Microsofts modern.IE website. As a result I have some more VirtualBox images, which are running Windows 7 and come with the propriate IE version.
The question is now how to access the Docker container in those Windows instances to test it under several IE versions.
What I have done so far:
Idea 1
To access the Django application I have looked up my local IP address and tried to access it via NAT in the Windows guests. Given my local IP adress 192.168.178.24, I have tried to access 192.168.178.24:1234 from Windows. Although I can ping 192.168.178.24 from Windows, I do get only a timeout on the port 1234.
Idea 2
Boot2docker runs a VirtualBox machine called boot2docker-vm. It comes with two network adapters, NAT and a host-only adapter called vboxnet0. The latter has the address 192.168.59.3 (which is the one which boot2docker ip returns) with the network mask 255.255.255.0. It runs a DHCP-Server on Server Adress 192.168.59.99 which gives addresses from 192.168.59.103-254.
I have added a second network adapter for my Windows guest systems which can also access via a host-only adapter the network vboxnet0. When being connected to the network the Windows machines do get a valid IP and can ping the IP 192.168.59.103. But I cannot connect to my Django instance on port 1234. If I try to call 192.168.59.103:1234 within Windows, I get a timeout.
Why is it not possible to connect to the Django instance? Can you help me? Thanks in advance.

I have found a solution to my problem here.
To get access to the Django instance I had to open the port on the boot2docker-vm machine.
This can be done by either by boot2docker-vm → settings → Network → Adapter 1 (NAT) → Port Forwarding and add a new rule where Host IPand Guest IP can be left empty and Host Port and Guest Port should be set to 1234.
Another way to do so is executing the following command in the command line
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port1234,tcp,,1234,,1234";
Of course this needs to be done for all ports, if more than one port is being used.

Related

How do I access an Oracle VM in my local network from another device?

I have following setup:
Windows 10 desktop with VirtualBox Oracle VM running
MacBook M1 which needs access to the Oracle VM
Windows desktop and MacBook are on the same local network
From my MacBook i'm able to ping my windows desktop's IP, but not the IP of the VirtualBox VM.
On the Oracle VM's settings I have a bridget adapter configured.
Is there a way to connect from my MacBook to the Oracle VM hosted on my Windows desktop in the same network?
Thanks in advance!
It depends on what type of network adapter you defined to the VM. In order to access from other machines on your LAN, you will need a BRIDGED adapter. Further, you will need to configure it (in the guest OS) with a manually assigned IP address in the same subnet as your other machines. My guess is you just took defaults and have only a NAT adapter.
I've built scores of VM's under VBox, and always create two adapters. The first is a NAT adapter, which allows my vm to access the internet - critical for downloading and installing packages with 'yum'. The second adapter is either HOSTONLY or BRIDGED. I use HOSTONLY if I want the VM to be totally isolated from the LAN and only accessible by the host or other vm's on the host. I used BRIDGED if I want to access the vm from other machines on the LAN. Either way, the BRIDGED or HOSTONLY need to be configured with a manually assigned ipv4 address in the same subnet as the host os.
I always create the NAT as the first adapter, and the BRIDGED or HOSTONLY as the second. On the os, the first (NAT) shows up as 'enps03' and the second as 'enps08'. I then configure enps08 with the following:
First, run the command below to set up the IP address. (substitute your chosen IP, but keep the '/24')
$ nmcli con mod enp0s8 ipv4.addresses 192.168.0.200/24
Next, configure the default gateway as shown - again, the first three octets of your subnet.
$ nmcli con mod enp0s8 ipv4.gateway 192.168.0.1
Next , set the addressing to static.
$ nmcli con mod enp0s8 ipv4.method manual
Set to start on boot
$ nmcli con mod enp0s8 connection.autoconnect yes
To save the changes, run the command
$ nmcli con up enp0s8
Reboot and check with ‘ifconfig’.

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!

How to create an SSH tunnel between Ubuntu Server (Virtual Machine) and Mac OS 10.8.5

I want to create an SSH tunnel between my virtual machine (Ubuntu server 12.04) and my MAC OS, the main thing is i want to access to the Ubuntu server from an external machine without
i have the IP address for the Ubuntu Server : 192.168.248.132
and the IP address of the MAC os : 172.20.3.90
I can access form the mac os to the Ubuntu server, but i want to access to the ubuntu server from an external machine.
Which VM you using?
You should create Network interface called Bridged Network - for VM Ware.
This way your Ubuntu will get real IP from local DHCP server - router in your case.
So IP become 172.20.XX.XX.
This should be enough to be accessed from local network.

Resources