Unable to access web app from outside docker container - docker

I have an ASP.Net Core web application running inside a container.
Docker for MacOS: 1.12.3
Container IP: 172.17.0.2
docker run -it -p 6000:6000 -v $(pwd):/workspace microsoft/dotnet:latest
which listens on http://*:6000
i'm able to curl the following from within the container & i'm getting the desired response.
curl http://localhost:6000 or curl http://172.17.0.2:6000
however, when i try to access the site from outside the container (on my MacOS) that's when i don't get any output.
Why am i unable to access from outside the container?

It was the port number, changed it and it worked.

Related

Dockerized Aurelia App Is Not Visible Outside of Docker Container - Not listening on 0.0.0.0

I'm running an Aurelia app inside of the standard node docker container and it is listening on port 8080. Within the container, I have tested that it's running using curl; and it responds with the expected HTML. But I cannot reach the app via the mapped port on the host (outside the container).
I'm running the following command to start the container
$ docker run -it --rm -p 8080:8080 -v ${PWD}:/app node bash
Then inside the container, I install the cli and create a new app
# npm install -g aurelia-cli
# au new
After creating a default app, I cd into the app directory and run the app.
# au run
As I said above, I can verify the app is running using curl http://localhost:8080. However, on the host, I cannot access the app:
$ curl http://localhost:8888
curl: (52) Empty reply from server
Originally, I thought this was a docker problem. See this question. But it turns out that Aurelia is listening on localhost rather than 0.0.0.0.
Running Aurelia with the host option set allows the server to listen on 0.0.0.0, so it will map properly in a docker container.
au run --host 0.0.0.0

I can't access my Docker container on GCP Compute Engine

I have my Docker container running on GCP Compute Engine. The CE server is running on CentOS 7. My Docker container has the application being served by Nginx with port 80 exposed. For some reason, I can't access it from the external IP address on my browser.
I ran the container with this command:
sudo docker run --name myapp -p 80:80 -d myapp:1.0.0
When I do sudo curl <internal_ip>:80 or sudo curl <localhost>:80 it will show that the application is running and returns back the content, but if I try to access in my browser with <external_ip>:80, it doesn't load anything. What can I do to make this accessible through the external IP address?
It seems I had to configure the firewall to open up port 80.

docker local host url not opening

I installed docker and with tensorflow image I am unable to open in browser with jupyter notebook.
What am I missing??
command used: docker run -it -v /home/$USER_NAME/tf_files:/tf_files gcr.io/tensorflow/tensorflow
where "gcr.io/tensorflow/tensorflow" is the tensorflow image and "/home/surya" is $HOME.
in terminal
output in browser
PS: docker installation is correct as "docker run hello-world" gives required message.
You missed to bind some ports. The official documentation of tensorflow provides the exposed ports with this command:
docker run -it -p 8888:8888 -v /home/surya/tf_files:/tf_files gcr.io/tensorflow/tensorflow
where -p 8888:8888 means: link the port 8888 of my local machine with the service in the container, which is also 8888. Then you can access the service at http://localhost:8888
Why do I have to map a port?
Your container shows the following:
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=1b3ec72ff1ed67f77a09beaee1dc4b9ad4e7aee26401b6f0
which means that you have to connect to the running process inside the container with the port 8888. To make the port of the container accessible from your local machine, you have to add -p 8888:8888 to your command. Then accessing the URL given to you from your container makes it possible to access the container's notebook via your local browser.

Accessing localhost of a docker container from the host

I am running the cloudera docker quickstart image (on windows) as explained on the this page.
I run it using:
docker run --hostname=quickstart.cloudera --privileged=true -t -i -p 7180:7180 -p 9080:9080 cloudera/quickstart:latest
It runs fine, I am able to run cloudera manager and access it using the url http://192.168.99.100:7180. So far so good. I also use tomcat with a simple app on localhost:9080 inside this same container. How do I access it on my host? I tried using http://192.168.99.100:9080 but it does not work.
Update: I fixed it by using the vm ip i.e. 192.168.99.100 instead of localhost for the server. Now it works. Thanks.

Docker in Docker: Port Mapping

I have found a similar thread, but failed to get it to work. So, the use case is
I start a container on my Linux host
docker run -i -t --privileged -p 8080:2375 mattgruter/doubledocker
When in that container, I want to start another one with GAE SDK devserver running.
At that, I need to access a running app from the host system browser.
When I start a container in the container as
docker run -i -t -p 2375:8080 image/name
I get an error saying that 2375 port is in use. I start the app, and can curl 0.0.0.0:8080 when inside both containers (when using another port 8080:8080 for example) but cannot preview the app from the host system, since lohalhost:8080 listens to 2375 port in the first container, and that port cannot be used when launching the second container.
I'm able to do that using the image jpetazzo/dind. The test I have done and worked (as an example):
From my host machine I run the container with docker installed:
docker run --privileged -t -i --rm -e LOG=file -p 18080:8080
jpetazzo/dind
Then inside the container I've pulled nginx image and run it with
docker run -d -p 8080:80 nginx
And from the host environment I can browse the nginx welcome page with http://localhost:18080
With the image you were using (mattgruter/doubledocker) I have some problem running it (something related to log attach).

Resources