Exposing Docker Container to outside world - docker

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.

Related

Is it possible to run a docker container embedding a GUI environment on a GUI-less server and open the GUI session from a remote GUI client?

I have a GUI-less server (fresh Debian without any desktop environment or Ubuntu server, without X server, a priori).
I consider to install docker and pull an official Ubuntu based container and add a desktop environment on it in order to use regular GUI apps.
I have a second computer in the LAN with a regular Debian Xfce or Xubuntu.
Is it possible to use this second computer to open the desktop session of the container (which is run on the GUI-less server) ?
(I would like to use standard Debian or Ubuntu packages as much as possible and avoid to use external PPA packages)
Small state of the art :
I have seen the NoMachine solution :
Build and Deploy NoMachine Desktops and Applications in Docker for Linux
https://www.nomachine.com/DT10O00161
My problem is that it is not explicit whether the docker is run on a GUI or GUI-less host. (And I would prefer to use a package from the Debian or Ubuntu repositories)
I have also seen the Consol docker images like :
consol/ubuntu-xfce-vnc
https://hub.docker.com/r/consol/ubuntu-xfce-vnc/
I am not sure but they also seem to run in a GUI-based environment.
I also have seen a solution using Xvfb and x11vnc (sorry it is a french webpage but I expect the translation to be ok with regular onlie tools) :
Utiliser VNC comme interface graphique avec un conteneur docker
https://www.geeketfier.fr/post/docker-display-on-windows/
This one also, I am not sure but this solution seems also be running on a GUI-based environment.
I found this docker image which solves my question : docker-x2go-xubuntu :
https://hub.docker.com/r/paimpozhil/docker-x2go-xubuntu
I built it on the GUI-less server and ran it as explained on docker hub.
On my second computer I opened an ssh tunnel to the GUIless server pointing to the docker interface :
ssh -CY -L 33333:container.docker.ip:2222 -l guilessuserlogin guiless.server.ip
(I retrieved the container IP by ifconfig on the GUIless server)
On this second computer I installed x2goclient from the regular repositories and configured a session to connect to localhost:33333
Once connected, the GUI desktop of the docker machine is completely available.

Accessing website hosted in a linux container from windows host

I have a linux container based on latest ruby image hosted in my windows laptop. I have a sample website running in the container. I can confirm that the website is running fine because running curl http://localhost:4000 with in the container returns the expected html. However, when I try to access the url from a browser in Windows it fails saying that it is not reachable. I am trying to figure out a way to access the sample app using browser in Windows.
Though I am trying to setup a ruby container (as I am trying to learn ruby), I am suspecting this is a networking problem with LCOW because I cannot ping the ip address of the container from Windows command prompt. It gives the error that "TTL expired in transit". Has anyone ever successfully tried a linux container on windows and accessing the website hosted in the container from windows? Could you please help me in figuring out what I am doing wrong or if I have to do something extra, like network route configuration, to make this working?
Further Details:
Docker version: 19.03.4
Host: Windows 10 Business Edition
Base Image: ruby on linux
docker run command used:
docker run -dit -p 4000:4000 --rm --name test updatedRubyImage
updatedRubyImage: This is a new image I created using base image. I installed a few gems on top of the base and commited it as a new image.

How to setup system of InfluxDB on Docker instance on Win10 to Connect to database from Windows system?

I would like to create a docker container hosting an InfluxDB as test environment for a Python project of mine. My PC is running under Win10, but Docker needs to provide a Linux-environment for the InfluxDB. I managed to install docker and influxDB (docker pull influxdb) and to create a database therein, so this part works fine. Docker's network configuration says it is on subnet address 10.0.75.0, subnet mask 255.255.255.0, which seems to fit to my DockerNAT when I do an ipconfig.
Now I want to connect to this Docker/InfluxDB "server" from my Windows10 environment (where PyCharm is running). I found this code snippet to connect to the DB via Python:
_influxClient = InfluxDBClient(host='localhost', port='8086')
but this yields a _influxClient = None
I have no idea how to proceed as I didn't find appropriate hints in the web. Or maybe I am using the whole Docker/InfluxDB etup wrongly? Any help appreciated.
The problem was, that I was running docker / influxDb with a local admin account, while I ran python as a normal user. As soon as I switched to running docker as normal user it worked.

Trying to get Xdebug session initiated in a docker inside a VM to reach my remote computer

I have a docker running my PHP app.
This docker needs to run inside a VM in a remote datacenter.
I work from a computer that can connect to the mentioned VM.
My intention is to have the Xdebug session that is initiated inside the docker reach my computer (more precisely my PHPStorm).
Both docker and the VM are running Centos (company approved/installed images).
The development computer is OSx.
I am able to use ssh remote forward (aka: tunnel) to forward any requests from the VM to my computer.
I want to either:
- be able to open a tunnel from my computer directly to the docker container in the VM
- or be able to continue the current tunnel in from the VM to the docker.
Have found no way to do the first option and have ran into a lot of issues trying to do the second.
Any suggestions?

Docker inside Windows VirtualBox

here's the thing: I tried to install docker inside a windows which runs inside virtualbox, and off course I failed due it's not possible (now I know this is due Hyper-V not used by virtualbox and required by docker).
Since for me migrating to VMWare ain't an option, I dig a little bit and found out that there's no problem on running docker inside a linux distro (which runs inside a vbox), so here's the question.
Is it possible to run 2 different virtual machines with virtualbox, one with linux (running docker inside it), and the other one with windows as my development environment, both at the same time and to develop on windows and then deploy and run tests on docker? If this is possible, how? Any links or keywords for me to search for would be appreciated.
Sure! You need to do following steps:
You should set your VMs network so then can see easily each other https://superuser.com/questions/119732/how-to-do-networking-between-virtual-machines-in-virtualbox
You should expose docker daemon on TCP socket on VM with linux https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd
On VM with windows you need to create some override for docker client so he will connect to remote daemon on linux machine https://gist.github.com/kekru/4e6d49b4290a4eebc7b597c07eaf61f2#create-bat-file-for-windows
Please keep in mind when you expose some service under ports you won't access that on VM with windows on localhost - instead of that you need to type: :

Resources