Finding Containers Using Docker VirtualBox - docker

I'm new to Docker and I'm Running macOS Sierra. I have installed Docker and can get the open Kitematic on localhost I can see my containers without issue and can access the site on localhost - when I switch to VirutalBox, my containers are no longer in Kitematic and I can't figure out how to access them in my browser.
Could anyone give me some insight on what to do here?

Your intention for getting the IP of your host(192.*) is unclear to me.
You can achieve this by simply adding the net flag in your docker instruction '--net host'
For more details go here.
If your intention is to make your container available to everyone, then there is no need to do it. Everyone should be able to access your docker container by accessing your machine's ip followed by port number (http://192.168.x.x:xxxx)

Related

Docker containers cannot be accessed from the internet but work when accessing from local network

First of all, sorry if I am not following the correct format for StackOverflow, this is my first time asking something here.
I am running Docker in an Ubuntu lxc in Proxmox but the Docker containers cannot be accessed from the internet. I am using Nginx Proxy Manager. Surprisingly, the containers worked well when I was running Docker desktop on Windows 11 but I switched to Ubuntu to try to make things easier and it didn't work so I tried Proxmox - which I had used before, and it is not working either. I have NGINX set up with Cloudflare and when I try to access for example, my Nextcloud container from the internet I get a "Web Server is down" (error code 521).
Everything works fine when I access from the local network. I can ping websites from both inside the container and the host with no lost packages so I know the containers have internet access.
I forgot to add that I have opened all the ports necessary for my Nextcloud container to work and I checked online with ismyportopen.com and it looks like the ports I need are open.

Updated windows docker and now it doesn't work outside localhost

I have been running a media cluster for sometime without any issues. I have everything networked into two different docker networks... the first network just bridges the docker instance to the local machine, the second network is a docker VPN container that I use for the other media services (an earlier version of what I am working on can be found here: https://github.com/Xander-Rudolph/MediaDocker)
The strangest thing happened today though. I ran the docker update for windows and now docker spools up without any errors or issues, however none of the services work outside of the machine running docker. Usually I have a poke through for a couple of the services in my router (namely wordpress/joomla which is on the bridge) and they work outside of my local network, but none of them are working anymore. I was able to confirm its not the DNS A record because I'm able to use the RDP ports I have mapped for my router, and when I test on another machine in the same network, it can't access the services via the internal IP (but it can RDP).
Anyone have any idea what could have changed to break this? I've already updated all my docker images and even rebuilt my VPN container (before I realized its a networking issue). What are some steps I can do to try to troubleshoot what is going wrong in docker to prevent access outside of localhost?
Update
I've been able to rule out the docker update as the root cause... I upgraded docker on my laptop (which was previously running the same version as my desktop) and its not having the same issue... this configuration must be localized to this desktop... No idea what the issue is... Will try a linux VM on the desktop instead of docker for windows...
Update 2
After a lot of screwing around in both a VM and in WSL, I'm still only able to access the docker services from localhost but not a different machine on my network or via the IP on the host machine (perhaps something similar to this: Can't access localhost via IP address). RDP does work so the computer is accessible but the services are not.
I'm not sure if this is a result of a docker networking config or a windows network config (I'm using WSL with docker installed on ubuntu 20.08) but I'm not seeing anything stick out. I'm going to remove the tag for docker windows but this is definitely an issue with networking and I suspect it has something to do with the fact that the containers are running behind a VPN... although I don't know why I would be able to access them on localhost but not the IP on another VM...
When I run
netstat -a -o
on WSL I can see the established ports on localhost... EX:
tcp 0 0 localhost:7878 localhost:37520 ESTABLISHED
but when I look on the host machine (for wsl) I don't see the connection. I tried to use netsh to create a firewall rule to see if that would help:
netsh advfirewall firewall add rule name="TCP Port 7878" dir=in localport=7878 protocol=TCP action=allow
but it didn't have any effect.
Any suggestions for ways to trace the network to see where/how its failing/getting blocked would be extremely helpful.
Your question: "...What are some steps I can do to try to troubleshoot what is going wrong in docker to prevent access outside of localhost?..."
Troubleshooting help for you, first do you have multiple networking adapters (Ethernet, Wi-Fi, etc.) present on the host. First ensure, the priority of these adapters needs to be configured in correct order so the Windows networking stack can correctly choose gateway routes.
Now, to fix this set your primary internet-connected networking adapter to have the lowest InterfaceMetric value, use can use these Powershell commands from an elevated console:
Get-NetIPInterface -AddressFamily IPv4 | Sort-Object -Property InterfaceMetric -Descending
Please ensure that the host's primary internet-connected network adapter has the lowest InterfaceMetric value.
// Use this command to make the change for e.g. lets say your
// primary adapter InterfaceAlias is 'Wi-Fi'
Set-NetIPInterface -InterfaceAlias 'Wi-Fi' -InterfaceMetric 3
Now step two, if your host's primary network adapter is bridged because you have an External virtual switch setup in Hyper-V, then you will set the external virtual switch to have the lowest InterfaceMetric value.
Lastly, confirm/verify your routing tables, when you run this, the last line should show the primary adapter's gateway address along with it's ifMetric value):
Get-NetRoute -AddressFamily IPv4
If you’re using Docker Toolbox then any port you publish with docker run -p will be published on the Toolbox VM’s private IP address.
docker-machine ip will tell you.
It is frequently
192.168.99.100
Taken from: https://forums.docker.com/t/cant-connect-to-container-on-localhost-with-port-mapping/52716/25
After several attempts using the references below, I was still not getting anywhere. The recommendation by #derple didn't get me anywhere (since I was in wsl) but the article he linked someone had said they switched to linux and uninstalled and reinstalled docker desktop... and for some stupid reason that works.
These are my exact steps I took to fix it:
Uninstall docker desktop
Install WSL and docker inside an ubuntu18.04 instance in wsl
Test docker in wsl with localhost (worked only on localhost still)
Uninstall WSL using windows add/remove features
reinstall docker desktop
Oddly the get-netipinterface and get-netroute look exactly the same as they did before I did the uninstall and reinstall but things seem to be working now... I have no idea why the above worked...

Exposing Docker Container to outside world

I'm currently learning Kubernetes as part of a project and facing a small hurdle which I hope you guys can help me in crossing.
The ask is to build a docker application that can be accessed over the internet by anyone anywhere. Below are the steps I followed.
I'm using Windows laptop
I used VMWare Workstation to install Ubuntu 20 LTS.
Inside Ubuntu, I've deployed my docker image - using ubuntu terminal
Currently, the applications are accessible within the ubuntu (using Localhost as well as, the URL generated by minikube (using the command minikube services <application_name> --url.
Since within Ubuntu my localhost is working I tried using the ip addr show to get my ubuntu's IP address and then tried accessing it from my windows machine and no result.
Now I want to use the postman installed on my windows machine to hit the container that's running within ubuntu.
I'm new to this entire process so apologies if my question sounds dumb.
First, make sure your network mode for your VMWare is "bridge" (as in here, for VirtualBox, but the same idea applies to VMWare Player)
Then you can use ngrok (as described in "Expose Docker Container services on the Internet using the ngrok docker image" from Lucas Jellema) to generates a public URL and ensures that all requests sent to that URL are forwarded to a local agent (running in its own, stand alone Docker container) that can then pass them on to the local service.

Stop nginx service that is started from docker container

I was watching nginx tutorial and for the purpose of follow up, I created Ubuntu 18.04 docker container. I installed and started nginx service as shown as in the tutorial and everything was going well. Then I removed both docker image and container that I'm working on. Despite removal of container and image, "http://104.200.23.232/" this address on my machine still returns nginx welcome page. As I think, this indicates that nginx service is still up and running. My question is that how can I stop and disable auto start of nginx service now?
Note: My host machine operating system is Windows 10 and restarting computer did not help to solve this problem.
Yeah, well blind guessing here but the IP "104.200.23.232" is registered for Linode which is a cloudhosting/vps provider, right? so probably not the IP of your local computer. Where did you get the reference for this ip? Did you try or install something on a cloudserver? I am pretty sure there are just some things mixed up.
Use "prune" to start fresh:
docker system prune
Try this to stop nginx in docker container:
service nginx stop

How can others run my docker image from my local network?

I've successfully created (using ubuntu VB) a docker image
What would be the best approach to let others from my local network run that image using ssh? I've been searching for quite some time and couldn't find anything that'd help.
I believe I have to map to a port somehow using the dockerfile and forward that port from my VM to my actual OS, but I don't know exactly how to do it or if it that's how is supposed to be done.
Any tips at all would be great help
TL;DR: Created a docker image using an ubuntu VB and I want others from my local network to be able to use it using ssh
Ok, made it work, here is how I did it:
Run the image
Use docker port [containerID] 80, to see the port of the running computer
Port forward that port from VirtualBox
settings
Set inbound / outbound rules for that specific port from windows firewall settings

Resources