Accessing docker container from Docker for Mac - docker

I have the following scenario:
Mac OS Catalina
Windows Virtual Machine running on VirtualBox
Docker for Mac (not docker-machine or Docker Toolbox)
I need to access a port that is exposed with docker run -p 80:80 nginx from the Windows VM and nothing seems to work. I tried NAT, bridge, socat... any hints?

Ah, I figured it out.
I can access the docker service by using the bridge interface IP (but not using localhost).
So in essence:
VM in VirtualBox should run in network bridged mode
use http://1.2.3.4 in the browser where 1.2.3.4 is your MacOS network interface IP address

Related

ip address is accessible from docker host, but not from docker container running on the host

There's some virtual machine internal network ip address which is accessible from MAC docker host. This was verified using ping.
However, the same ip address is not accessible from any docker container running on the Docker host.
I tried to run container with --network host, however the ip is still not reachable.
Then, I discovered that none of the VMs reachable from MAC docker host are reachable from any docker container running on it.
How to debug and solve this issue?
External ip addresses (of google.com ) are accessible from the container.
I performed the same test on Linux docker host. The same internal VM ip address was reachable from within the container as well as all other VMs.
It's important to note that MAC docker host is just MAC machine connecting to the network using VPN and thus getting access to internal network VMs.
Linux Docker host is VM itself in the internal network where VMs are located.
I'm using 3.6.0 MAC Docker desktop version and update regularly.

Howto access a service in a docker container from VM?

I have an Ubuntu host with a web app running inside a docker container.
The web app is accessible from Ubuntu PC via 172.19.0.XXX:8080.
Now I want to test how web app looks like in IE. For that I started VirtualBox with Win7.
How could I call web app from VM?
Already tried different VM network variants, such as default NAT with port forwarding; and bridge - without any luck
Thanks in advance!
You can map the ports between the docker container and the Ubuntu host when starting the container by using -p 8080:8080, then you should be able to connect from Ubuntu using localhost:8080
Once you do that, find the IP address of the Ubuntu host by running ifconfig and use that IP to connect from the Windows VM via http://<Ubuntu-ip>:8080

Equivalent to boot2docker ip for new docker for windows10/hyperV

I have used docker toolbox in the past on windows with Virtualbox and boot2docker. Now I installed new docker windows and boot2docker is not recognized anymore when typing
boot2docker ip
What command should I use now for Docker Windows ?
It should be localhost. Docker for Windows (as well as Docker for Mac) are doing some additional magic proxying to automatically forward ports from the host to the IP address of the VM so you shouldn't need to know the IP.
However, there are some caveats on Windows. Check out https://docs.docker.com/docker-for-windows/troubleshoot/#limitations-of-windows-containers-for-localhost-and-published-ports for more information if you are using Windows containers.

docker running splash container but localhost does not load (windows 10)

I am following this tutorial to use splash to help with scraping webpages.I installed Docker toolbox and did these two steps:
$ docker pull scrapinghub/splash
$ docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 scrapinghub/splash
I think it is running correctly, based on the prompted message in Docker window, which looks like this:
However, when I open the `localhost:8050' in a web browser, it says the localhost is not working.
What might have gone wrong in this case? Thanks!
You have mapped the port to your docker host (the VM), but you have not port-forwarded that same port to your actual "localhost" (your Windows host)
You need to declare that port-forwarding in the Network settings of your VM (for instance "default"), or with VBoxManage controlvm commands.
Then and only then could you access that port (used by your VM) from your Windows host (localhost).
That or you can access that same port using the IP address of your boot2docker VM: see docker-machine ls.
#user3768495, when you use http://192.168.99.100:8050/ , you are actually using the docker-machine ip and this ip would be available on your machine only and not on the network. To map it to localhost, you do need to port-forward the same port to your localhost. I was having the same issue and I detailed the process in below link.
https://stackoverflow.com/a/35737787/4820675

docker-machine osx port forwarding

How does port forwarding work with docker-machine?
I recently installed the docker toolkit and spun up a container. However I cannot reach it on my local mac as.
Is this Port forwarding in docker-machine? using VBoxManage the best way to access the running docker container using my OSX browser?
To add port forwards from the command line to a running boot2docker VM use the following command:
VBoxManage controlvm boot2docker-vm natpf1 "default,tcp,127.0.0.1,1234,,1234"
After restarting kitematic & the docker-host default VM. The container appeared in kitematic and the bound URL.

Resources