Howto access a service in a docker container from VM? - docker

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

Related

Docker container deployed in Linux environment

This is what I'm trying to do. I have created a docker container and have it deployed in my Linux Putty environment. I am now trying to view the website I deployed on my Windows Chrome browser. When I try accessing localhost upon running the container, I am getting "This site can't be reached". Below is the command I used to run the container:
docker run -d --name testContainer -p 80:80 static-app:v1
Any advice on how I can access this would be helpful.
I am assuming these two words as
1- Linux putty environment: Linux VM running on windows( oracle etc..) you connected this through putty
2- website I deployed on my Windows Chrome browser: trying to access container through chrome as port is exposed
if above mentioned case is correct then:
port exposed is between host and container is 80:80, here host mean where your docker is running, in your case its Linux environment. you can not see that on windows chrome browser.
Specify if the situation is different.

Accessing docker container from Docker for Mac

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

How to access the container server in Docker Toolbox

I am running a container in localhost with Python Django (python manage.py runserver 0.0.0.0:80) and I want to access this service in my wifi network...
When I run the server locally (no Docker), it works fine, I can put the IP of my computer in my phone's browser and access the web app.
My PC is not Windows Pro, and I run the Docker Toolbox version which use the VirtualBox to do the Docker stuff. For this reason, the container IP address is 192.168.99.100, and my PC IP is 192.168.0.5
How can I access the docker machine from my phone??
if u have mapped ur conatiner port to some host port, then you should be able to access your app using your the ip of your computer in your wifi network and the mapped port.

connect to server runned in windows docker container

I am a newbie with docker. I need to use it at windows 7*64 , via docker toolbox. I need to make a connection to server below:
Run the server:
docker run -p 4444:4444 mycontainerWithServer
After this i open new docker toolbox window and try to connect to localhost:4444. I get ConnectionRefused error.
Because you are using the Docker toolbox you don't access your containers on localhost. The toolbox uses 192.168.99.100 by default because it is running on a Linux VM. Try replacing localhost with the VM IP.

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

Resources