Accessing website hosted in a linux container from windows host - docker

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.

Related

Unable to connect with Xdebug from a Docker container inside and WSL2 instance

I have to do PHP development, for this I was given an Windows 10 machine, this is something I cannot change. So I use the WSL2 feature to setup and development server using Ubuntu 20.04.
First attempt:
Used Windows with Docker Desktop. I configured the environment but was had issues. The mapping between of the project volume and Docker caused important processed like Composer, git etc to be very slow. So this is considered unworkable for me.
Second attempt:
Setup a development environment directly in the WSL2 instance. This works. I'm able to connect with the Xdebug debugger using PhpStorm. But again the rest of the operations are very slow and is considered unworkable for me.
Third attempt:
I was advised to do the following: Create WSL2 Ubuntu 20.04 instance. Install docker on it and store the project folder directly in \\wsl$. In this WSL2 instance I run a docker webserver container. The webserver becomes accessible by localhost.
This seems to work very good, not sure why though... The websites running on the docker webserver are very fast and executing git or composer commands are fast. I open the project folder directly from the \\wsl$ location with PhpStorm.
The only issue I'm having is that I'm unable to create Xdebug session using PhpStorm.
My question is: How to configure the development environment so I can use Xdebug?
Facts & specs
Windows 10 as host machine.
WSL instance: Ubuntu 20.04
Docker webserver instance: Ubuntu 20.04 (php7.4-fmp and apache2, xdebug 3.0.3 port 9000)
The docker webserver container can access the host network (192.x.x.x.)
The docker webserver container can access the WSL network (172.20.x.x)
I use the following xdebug settings:
xdebug.mode = debug
xdebug.client_host = host.docker.internal (this goes to the 192.x.x. address)
Any advise on how to make Xdebug work in this setup?

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.

issue with docker container with .net core 3.1 web app

I have created an MVC project with .net core 3.1 and enabled docker support, so I have the docker file in the project.
I am using Windows 10 Enterprise and Docker desktop community client for windows and it is running as a Windows container.
When I compile the project from the Visual Studio 2019, it creates the image and then the container, and by running: "docker container ls" I see it running.
I had to inspect the container to see the IP of the container and be able to run the page from the URL coming from the container. So having the IP of the container (172.24.121.233), I put this in the browser: http://172.24.121.233:80 and I see my web page. But the issue is after I stop running the MVC app from Visual Studio this URL does not work anymore?
I was expecting it to run independently? Any help to solve this issue and get the container running independently from Visual Studio?
Thanks
of course, you can run the docker container again: first, run docker ps -a (or if you don't run the container at all, docker images -a), find your container (or image) and run it by the command docker run <IMAGE_NAME>
Two hints:
if you want to detach from the container after running it, use -d switch
if you want to access port 80 of your image without finding the container IP, use -p 180:80 and use your port 180 of host machine

Cannot download Docker images - no such host

I have a web app on my home PC, which uses Docker. It works as expected.
I have installed Docker on my work PC. So far I have run: docker run hello-world and I see an expected result:
I then try: docker run --name some-mongo -d mongo:tag and I see this:
I have spent a lot of time looking into this. So far I have tried (in Docker for Windows Settings):
1) In Proxies; check 'Manual proxy configuration' and specify: http://proxy1:8080 as http and https proxy server (this is what is specified in Internet Settings).
2) In Network specify a fixed DNS server of: 8.8.8.8.
This has made no difference. What is the problem? Do I need to pass my username and password to the proxy server? I am confused why the command in screenshot 1 works as expected whilst the command in screenshot 2 does not.
I have Docker for Windows on a Windows 10 PC. I am using Linux containers.

Docker client on Windows Subsystem for Linux (Ubuntu) mounts (near) empty directory

I have Windows 10 with Windows Subsystem for Linux installed (Bash on Ubuntu on Windows), have Docker installed on Windows, and a Docker client running on the linux subsystem per this walkthrough. All works well, however, when I want to be able to access a volume on my default mount "/mnt/c/../". I am using the mount flags at docker launch and have tried both:
docker run -v $PWD:/mount
docker run --mount type=bind,source="$(PWD)",target=/mount
and most variations shown here.
I have reason to think this is a permissions issue. When launching from the linux subsystem, there is always one empty folder from the original source directory. When launching from windows powershell, everything is fine. The only difference between the two would be the docker client being used.
I have shared C in the docker host settings in windows, however, do I need to do something similar for the client inside of windows subsystem for linux?
Versions:
Docker client: Docker version 18.03.0-ce, build 0520e24
Docker host: Docker version 18.03.0-ce-win59 (16762)
I had the same issue with the same set-up. After a lot of trial and error and googling, here is what resolved the issue:
Change Windows password to not include special characters.
Reset credentials for docker.
Worked! Weird bug.

Resources