What is serving my nginx on the docker? [closed]

I got the cheapest VPS on Digital Ocean.

I followed this guide, everything works like a charm..

But now I want to serve multiple nameservers on the same ip, so I need to figure it out how this is really working.. I have basically no knowledge about docker..

I read I can log into my docker with

./launcher ssh my_container

I did and it works, I can see the nginx configurations and so on.

Now my question is: how the nginx inside the docker is interacting with the public requests?

I mean, I did find no web server on the local VPS, neither apache or nginx… so is the nginx from the docker responding directly?

Edit: I do have a Docker0 interface

This is my iptable

root@droplet0:~# iptables -L -v
Chain INPUT (policy ACCEPT 63619 packets, 21M bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
77364   33M ACCEPT     tcp  --  !docker0 docker0  anywhere             172.17.0.19          tcp dpt:http
   10   400 ACCEPT     tcp  --  !docker0 docker0  anywhere             172.17.0.19          tcp dpt:ssh
40958   25M ACCEPT     all  --  any    docker0  anywhere             anywhere             ctstate RELATED,ESTABLISHED
 104K   35M ACCEPT     all  --  docker0 !docker0  anywhere             anywhere            
    0     0 ACCEPT     all  --  docker0 docker0  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT 79829 packets, 17M bytes)
 pkts bytes target     prot opt in     out     source               destination    

I dont understand, the Docker0 has another ip (anyway always in the same subnet), so who is the traffic being forwarded to? Is there a third part between the host and the docker?

Answer

Without knowing information I can’t say for sure, but it sounds very likely that nginx running within Docker is what is serving up the page. I would first suggest you familiarize yourself with Docker: https://www.docker.com/tryit/

Remember that changes to a Docker container are not persistent. You have to save the current state in an image. When you launch a container using the new image, it will have your changes in it. One of the simplest ways to update configs on an image is to use an existing one in a Dockerfile http://docs.docker.com/reference/builder/. You could create the configs and web page files as you’re used to doing, then use the ADD directive to place them in the correct location in your image. When you launch this new image, nginx will see the configs for these web pages and load them.

Docker networking by default creates an interface called Docker0. It can expose a port on the Docker container to the host’s interface, so likely it is exposed on port 80 on your host. The docker container could be using any port on the Docker interface. They can be mapped sort of like a NAT translation with a firewall.

Attribution
Source : Link , Question Author : elect , Answer Author : theterribletrivium

Leave a Comment