Accessing Linux container from Windows host - docker-networking

I have Linux (CentOS-7) containers which are running on top of Windows docker host. I can ping from Linux container (172.17.x.x) to Windows host (10.10.x.x) but I cannot do the opposite. My Windows version is 10 (firewall off).

Related

Unable to access jupyter notebook on virtualbox guest through browser in windows host

I have virtualbox 6.1 running a ubuntu 20.04 LTS guest on a windows 10 host.
I ran a jupyter notebook on the ubuntu guest. and it gave me this output
http://localhost:8888/?token=749e04f283016d.......
or http://127.0.0.1:8888/?token=749e04f283016d.......
I got to know that I have to setup host-only adapter to access the page on windows 10 browser so I have setup host-only adapter along with NAT adapter for the ubuntu guest.
accessing-your-virtualbox-guest-from-your-host-os
Post that I took the host-only adapter interface IP address using ip a command in ubuntu guest and I am able to ping guest from host as well using that IP. But when I replaced it in the above url, I am still unable to access the link and browser running on windows host says ERR_CONNECTION_REFUSED.
What additional setup should I do to access the jupyter page from windows host.
I figured it out from the following post which tells the same thing about ipython notebook
Install IPython on Ubuntu 12.04 VirtualBox Guest and use it from the browser on the Windows Hostenter link description here
and finding out from this answer the main difference between jupyter and ipython notebooks.
What-is-the-difference-between-Jupyter-and-IPython-Notebook
The key thing to note here is that many applications when started eg. mongodb are accessible only on loopback interface IPs(localhost, 127.0.0.1) only. the reason being to avoid exposing by mistake any application on public IPs which u might have installed for testing, etc. So, in this case all you have to is generate a config file for jupyter server using :
jupyter notebook --generate-config
which will generate config file :
~/.jupyter/jupyter_notebook_config.py
where you have to change the following line:
c.NotebookApp.ip="localhost"
to
c.Notebook.ip="0.0.0.0" #for all IPs
Now run the jupyter notebook again and you will be able to access it on your host and even any interface IPs for any adapter you have setup for your guest OS.
A few things to review when running Jupyter inside a virtual machine.
Make sure you have added the Jupyter's port (i.e., 8888) to your Ubuntu firewall
sudo firewall-cmd --permanent --add-port 8888/tcp
sudo firewall-cmd --permanent --add-port 8888/udp
sudo firewall-cmd --reload
When using VirtualBox you should map ports to the VM.

.NET Core application on WSL2 Ubuntu 18.04 LTS cannot talk to RabbitMQ running in Windows Docker

NOTE: MOVED here from SuperUser, where it didn't generate any response.
I have a application built on the latest .NET Core 3 which was released this week. I am having a problem while running under WSL with Ubuntu 18.04 LTS. Problem is an exception opening up RabbitMQ communication:
connection refused 127.0.0.1:5672
Port 5672 is a RabbitMQ instance running under Docker on the Windows side. The same .NET Core 3.0 app connects to the port and functions fine running under Windows that WSL2 Ubuntu is failing.
Do I need to configure WSL2 in some way to open that port to Ubuntu?
I can ping localhost and 127.0.0.1 under ubuntu
netstat -a under ubuntu doesn't return much and nothing about 5672/RabbitMQ
on Windows/powershell 'GetProcess -Id (GetNetTCPConnection -LocalPort 5672).OwningProcess' makes sense and returns docker...
.NET not installed but the application was built with 'dotnet publish -r ubuntu.16.04-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed'
The code opening RabbitMQ as requested.
public MessagesManager( string channelname, string host = "localhost" )
{
// real code passes username/pwd
var factory = new ConnectionFactory() { HostName = host };
_connectionMQ = factory.CreateConnection();

How can i configure the macOS firewall to access my docker nginx container?

MacOS firewall is preventing me from accessing my docker nginx container
I can use my domain name to get to non-docker nginx running on my laptop.
I cannot use my domain name to get to docker nginx running on my laptop unless I disable the macOS firewall.
docker nginx is running on port 80
docker nginx is accessible with curl localhost
When I turn off my macOS firewall I can access my docker nginx.
How can i configure the macOS firewall to access my docker nginx container?
macOS is failing to recognize the connection attempts to ask if it should allow them.
We added app: bundleid = com.ht.kubecontext to allow in the firewall config on macOS and magically connections worked. Not sure if this is a bug in docker.app not including kube connections to its context when enabled or a macOS sensing failure, but this unblocked us on the issue.
Here are the settings which will prevent MacOS firewall from blocking :
Ngnix port > 8000
Public Port : 80

Can not access nginx container on a local windows machine

I'm running an nginx container on a windows 10 machine. I've stripped it down to a bare minimum - an nginx image provided in the Docker hub. I'm running it using:
docker run --name ng -d -P nginx
This is the output of docker ps:
b5411ff47ca6 nginx "nginx -g 'daemon off" 22 seconds ago Up 21 seconds 0.0.0.0:32771->80/tcp, 0.0.0.0:32770->443/tcp ng
And this is the IP I'm getting when doing docker inspect ng: "IPAddress": "172.17.0.2"
So, the next thing I'm trying to do is access the Nginx server from the host machine by opening http://172.17.0.2:32771 in browser of the host machine. This is not working (host not found etc).
Please advise
On windows, you are using Docker Toolbox, and the IP you need is 192.168.99.100 (which is the IP of the Docker Toolbox VM). The IP you got is the IP of the container inside the VM, which is not accessible directly from Windows.
Follow this article... https://docs.docker.com/get-started/part2/#run-the-app
And make sure your application is running not just docker.
docker run -d -p 4000:80 friendlyhello
After this on Windows 10 host machine
Worked http://192.168.99.100:4000/
Not working: http://localhost:4000/
I used the following command to map the internal port 80 on the running container to port 82 off localhost:
docker run --name webserver2 -d -p 82:80 nginx
accessing nginx image off localhost:82 works great.
The port you want to access from your local web browser is the first number before the :80 which is where nginx image runs virtually in the container.
There is lots of miscommunication out there on the issue -- it's a simple port mapping between the host machine (Windows you are running) and the container running on docker.

connecting to my local virtualized debian

I have installed Debian as a VirtualBox guest on Windows XP. Now I have installed ssh and apache on this virtualized Debian yet I couldn't find a way to connect. I have already tried "10.0.0.2", "10.0.2.2" and inet addresses I get from running "ifconfig". (I can get the "it works!" page of apache2 when I try 127.0.0.1 under guest Debian.
I will be greatful for any tips
You're going to want to refer to section 6.4.1 of the manual to set up port forwarding with the default NAT setup.

Resources