How to view Docker Application in the Browser - docker

I have run the following command to have a Docker application (ASP.NET Core) run on Windows desktop:
docker run --name eshopweb --rm -it -p 8000:5106 web
The console outputs the following:
Hosting environmnet: Production
Context root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
When visiting the following URL, localhost refused to connect.
http://localhost:5106/
How can a Docker application be viewed in the browser?

According to the output, the application is listening on 80;
You need to expose the port 80 of your container.
Do something like:
docker run -dit -p 8000:5106 -p 10080:80 --name eshopweb web
And then try: http://localhost:10080

8000 is your external port while 5106 is internal port of the container. Try http://localhost:8000/

Related

Run docker image on specific port

I am new to Docker.
I was trying to dockerize a simple static website using nginx base image.
The applicatio runs fine on local server when i run.
docker run -d -P <container-name>
So, here the app runs on some random port on which i am able to see my app running.
while, when i try to specify port by using the following command:
docker run -d -p 5000:5000 --restart=always --name app mkd63/leo-electricals
The page at localhost:5000 shows site cant be reached.
My Dockerfile is:
FROM nginx:alpine
COPY . /usr/share/nginx/html
EXPOSE 5000
By default, the nginx image listens on port 80 inside the container.
Publishing a port creates a port forward from the host into the container. This doesn't modify what port the application is listening on inside the container, so if you forward to an unused port, you won't connect to anything.
Exposing a port in the Dockerfile is documentation by the image creator to those running the image, but doesn't modify container networking or have any control over what the application running inside the container is doing. With docker, the -P flag uses that documentation to publish every exposed port.
To map port 5000 on the host to nginx listening on port 80 inside the container, use:
docker run -d -p 5000:80 --restart=always --name app mkd63/leo-electric

How to intercept Docker's container traffic with Burp?

I did the following:
Run docker pull bkimminich/juice-shop
Run docker run --rm -p 3000:3000 bkimminich/juice-shop
Browse to http://localhost:3000 with Burp listening to 127.0.0.1:8080 => I see external traffic (google, cdn...) but not internal (Docker container).
So please how to configure my container to connect it with my proxy Burp. Burp is installed on Windows not inside the container. Thks
While running Docker Pull, did you try to run it with 8080 port.
If the problem is not resolved, try to open port 3000 from Burp Suite / Proxy / Settings.
If there is a certificate setting in the Docker container, I suggest you check it.

Run docker but get This site can’t be reached 192.168.99.100 refused to connect

I unable to access docker exposed port on windows machine. In details I do the following:
$ docker build -t abc01 .
$ docker run -d -p 80:4000 abc01
Then I try to reach docker container in browser:
http://192.168.99.100:4000
and get annoying result:
This site can’t be reached 192.168.99.100 refused to connect.
What is the issue?
You are exposing the right ports, however, you need to access the website at: 80 instead of 4000, given that 4000 is the port on which your application is listening.
The way exposing ports in Docker works is as follows:
docker run -p 80:4000 myImage
where
80[is the outside port]
The one is exposed on your host and you will use it in your browser
4000 [is the inside port]
The port that is used inside the container by the application

Access apache inside ubuntu container

I have apache installed inside a running ubuntu:14.04 container. How to access this in the browser of the host machine? The address showing inside the container is, 172.17.0.2. Please help.
By default, the apache httpd image exposes the port 80
docker run -it --rm --name my-apache-app -v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4
So http://localhost should be enough.
In your case, make sure:
the httpd is actually running (docker exec -it <yourContainer> bash: ps -eaf),
you have mapped the port you are running Apache in your container to the host (-p 80:80 for instance).
By default, the apache image exposes the port 80, but you need config this in run command (-p):
docker run -d -p 80:80 httpd
The first number is port of Docker Host and the second one is port of container. This configuration will map all connections to port tcp 80 of docker host to the same port of container.
After that you can access your application in your browser, using 127.0.0.1, localhost or other IP Address of your interface.

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