Addressing localhost from ubuntu to windows 8 via Virtualbox - docker

I'm developing a simple web application with springboot in Windows 8.
When I deploy jar file into docker in Ubuntu and run the container, I can see it works on address 10.0.2.15:8082 which is a local IP address, correctly.
What I want is to connect this IP address in my Windows 8 then I will use postman to post some JSON variables etc. But I can't connect 10.0.2.15:8082 from Windows 8.
My VirtualBox adapter attached to NAT and also some rules are given:
I also tried to change host and guest rules otherwise, but didnt work either.
When I run the application in Windows 8 and check it with 192.168.56.1:8082, it gives success and also I can see the same result in Ubuntu with the same address. but can't get it to work otherwise.
I expect to connect ubuntu's localhost in my Windows 8.

I have found the answer;
After shutting down vm, i added second adapter as Host-only Adapter. After starting virtual machine, in terminal by entering "ifconfig" command you can see ip4 address for host-only adapter (in Windows it is Ethernet adapter Virtualbox Host-Only Network). When you try to enter that address in windows and ubuntu, it shows the result.
Also that 192.168.56.1 address is Windows Virtualbox Host-Only Network IPv4 address in my PC.

I believe NAT adapters do not allow direct connection between host and guest, you will need a second Host-only Adapter for that purpose.
See this link for a nice explanation.

Related

Accessing Docker running on Host machine from VMWare Workstation VM

I have the following setup:
Windows 10 Host (Hyper-V enabled)
Docker Desktop installed on host
VMWare Workstation Pro (16)
Windows 10 VM - Docker CLI installed on vm
The Windows 10 VM is used as a dev environment, with project-specific stuff on there.
I also use the host as a development machine for other projects - so want to be able to use docker on both.
What I'd like to do is access the docker engine running on the host, from my VM
By access docker, I mean use the docker cli to run containers, build images etc... setting DOCKER_HOST or something like that?
Is this possible? Or any other way?
So far, I've set my VM to use NAT networking and tried:
docker -H tcp://192.168.126.2:2375 images
Which returns
error during connect: Get http://192.168.126.2:2375/v1.40/images/json: dial tcp 192.168.126.2:2375: connectex: No connection could be made because the target machine actively refused it.
192.168.126.2 is the ip of the default gateway, from within the VM (so - my host?)
On the host machine, if I do docker -H tcp://0.0.0.0:2375 images I get the expected result.
On the host machine, I've also set:
"hosts": ["tcp://0.0.0.0:2375"],
within the docker engine config:
so what i would do and usually am doing is in VMware Workstation in Network editor I connect VMs to a bridge and select my main line that provides connectivity whether it is an Ethernet port or Wifi and associate it to lets say VMnet0. Then in VM settings I assign that VM's NIC to VMnet0 and that is how my VM and my host are on same LAN.
I would not use NAT.

RDP on Vmware workstation 15

Sorry for the newbie question.
I just installed Vmare workstation and created a windows server 2012 virtual machine(Set up remote desktop on the server 2012)
The virtual machine is hosted on the below Ip.
The virtual machine Ip.
Adapter settings
Nat Settings
When remote desktop from 192.168.2.120(virtual machine host) to 192.168.88.128 the remote desktop work fine , but when trying from a different PC on the same network(192.168.2.107) to remote desktop to (192.168.88.128) then remote desktop can be access.
The problem in your case is the adapter option you are using in VMWare for your Windows Server. Rather than using a NAT adapter use the Bridged option.
Your answer ends above but if you need a bit insight of your problem then you can read the further part. The NAT IP of Windows server which is the guest machine (192.168.88.128) is reachable from the host machine(192.168.2.120) just because your host machine is internally connected (via a virtual switch) to the guest machine. If you check the network adapters in your host machine then you will find an adapter which will have an IP (192.168.88.1). Your host machine is communicating with your guest machine via this adapter.
The NAT option hides your virtual machine from the physical network. If you want to reach your machine then you have to configure some routing table entries to route packets (heading towards your VM) to your host machine and then again in your host machine you have to write a static route so that the packet received on 192.168.2.120 is forwarded to 192.168.88.0/24

Allow a container running via docker-machine to connect with Mysql or XDEBUG port on parent OSX system without using an OSX DHCP assigned ip address?

I've got the following setup:
OSX running MySQL listening on all network adaptors at port 3306
XDEBUG enabled IDE listening on port 9000 on the base OSX system.
docker-machine host running on the OSX system with the host ip 192.168.99.100
A debian based docker container with a mysql client running on the docker host and HHVM running with xdebug looking to connect to some lucky remote host on port 9000.
The ip addresses change frequently on the OSX system due to being assigned via DHCP, so I want the docker container to be able to somehow be able to hit the mysql server regardless of what IP the native OSX network adaptors get assigned (without manually updating it). Also, I need a stable ip I can provide my HHVM server.ini file a remotes host for Xdebug.
With running a base system of linux this isn't an issue as the docker host and the actual native machine running docker are one-and-the-same. Also, there are several ways for a container to learn of the host's ip so the issue isn't hitting the docker host.
However, in OSX running docker-machine, the host ain't the native OSX system, but instead is a VM running in virtual box (assuming you're using the vb driver, and who the sam hill blazes isn't?).
The only thing I could think of was to port forward request on 3306 to the docker-machine host (192.168.99.100 which never changes) to the OSX's port 3306. Then have the container hit the docker-machine host for Mysql requests. IF this works, I could rinse and repeat for any port I port I need to link like xdebug on port 9000.
Does anyone know how to accomplish this or have another suggestion?
Figured a way out without needing to make any changes that provides a consistent ip to connect to on the base OSX system. Docker machine sets things up in such a way to make this possible.
Docker machine creates a virtualbox VM with 2 network adaptors, one set up as host-only, the other set as NAT. Don't know why it creates 2, but
The host-only adaptor provides the OSX an ip of 192.168.99.1 and the various VM's using it get addresses starting with 192.168.99.100. However, inside the VM network, you can't use the address 192.168.99.1 to hit ports on the parent OSX system (not sure why, but guessing host only intends to be only communication between the VMs).
The NAT network adaptor is set so the OSX get's the ip 10.0.2.2 and the VM get's 10.0.2.15. With a NAT, you can route to the OSX system at 10.0.2.2 from both the docker host VM and containers running on the host.
Since this 10.0.2.2 address for the OSX machine doesn't change (unless you screw with the virtual box networking settings) bingo, got what I need.

Use VirtualBox to access site on host from guest? the host and guest is linux

I'm running VirtualBox on a ubuntu (host), the VM i'm using is fedora (guest). VirtualBox is setup to use the NAT network adapter, and I'm able to get to the internet.
i use Port Forwarding to access ssh and the rails web server
port Forwarding Rules
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
<Forwarding name="Rule 1" proto="1" hostport="5679" guestport="22"/>
<Forwarding name="Rule 2" proto="1" hostport="3080" guestport="3000"/>
</NAT>
now i can access internet on guest machine , and i can logging through ssh
but i cannot access the Rails web server on port 3080
i tried :
localhost:3080
10.0.2.15:3080 #the guest IP
what i can do all i need is SSH and internet connection and open the web site i host on gust machine by Browser in host machine
thanks
Just a stab in the dark here but this might be your issue...
When you provision a new Linux Virtual Machine in VirtualBox, the Network settings for that VM are set to 'NAT'. This results in your new VM being assigned a 10.x.x.x address.
Change this setting to Bridged mode, which will assign your VM an address within the same subnet as your host (most likely 192.168.x.x).
Try to connect to the site running on your host.
If you're still not able to access the site running on localhost, confirm the app isn't blocking connections from your new VM. Add a rule in to your access list (possible iptables) permitting tcp port 80 traffic from your VM's address (found using ifconfig).
Happy hunting!
In your VB you have to set network only with host. It is in preferences->network.
Then you can access your virtual machine via 192.168.56.101 from ubuntu. Port forwarding set on this network card. List it with ifconfig. I recommend to use iptables for port redirects.

get VM IP address on Windows

I am running a Debian VMware virtual machine on Windows7. I am developing a Rails web app on the virtual machine, I would like to access the app (localhost:3000) from outside the vm, i.e from windows.
Is there a way to do that?
Thanks.
This really depends on how your virtual network adapters are setup between the guest and host. Assuming you have not changed anything, they will be bridged by default. In your VM from a terminal run:
ifconfig
This will give you the IPv4 address (generally a 10.x.x.x) of the virtual interface which you should be able to access from your Windows host. You should be able to put that into your browser on the host with the :3000 port and access it.
If you have modified the network adapters, things may be different. For instance, setting it up as a NAT will give it an address on your physical network; i.e. 192.x.x.x, but accessing it the same. A host only netowork, would also most likely provide a 10.x.x.x address, but should also provide access.

Resources