0

Technically i shouldn't be asking this question as i was already able to successfully accomplish it, however i did not record any of my notes/findings on it and i was forced to delete the centos VM it was on as it would not boot properly. So now its FUBAR and need to remember what i did.

The challange for me was to have 3 different docker containers. A npm repo container, a bower container (Link in comment 1), and controlled by a nginx container. The npm repo and the bower had to be able to access the same IP address but down different ports and be accessed via special names like bower.swig.swag. or npm.swig.swag. The port handling would have been taken care of by the nginx container and would in turn have any containers desiring to be accessed at the IP address to attach the --env flag of VIRTUAL_HOST= (As stated from the docker info on the nginx link).

So the IP that was desired for the npm containers and bower containers was 10.1.10.1 down ports 8080:8080 and 5678:5678 respectively. I think the DNS server was 10.1.10.30 or it was based on the localhost, however i cant really be sure at the moment as almost all IP's i try to provide, excluding the localhost 127.0.0.1 and 10.0.2.15 do not work with relationship to the docker run -p flag (i have no idea why this happened. One minute, any ip i provide to docker works and after deleting it, it does not. I got a link to the error here in comment 2. Stupid link rule.) Nginx was targeted to the local host if im remembering this correctly. Down port 80:80.

I cant remember the exact flags i used, but here are some of the possible flags i needed to run with docker. They were a mix of

docker run 
-p, --dns=, --env=VIRTUAL_HOST=, -h, --expose

When we specified the virtual host for the container, we also had to modify something in the vim/vi file of /etc/hosts but i cant remember how i am supposed to add it. In the end, someone should be able to take the specified virtual host name, go into a browsers http bar and type, http://virtualhostname and be granted access to the website. Thats how i knew it was working. Think anybody can get me back on track? (Will be posting this to stack overflow as well. I cant really balance between which site to use so i might as well.)

3

1 Answer 1

0

While the IP Issue remains, (according to nmap, almost all of my ip's are being filtered and currently have no way to fix this.), ive still been able to succesfully recreate what i did on the localhost.

The nginx docker information contains information about --env=VIRTUAL_PORT=. This is used to work different ports down the nginx server. When combined with --env=VIRTUAL_HOST=, this allows the allias to be bound to the ip address following the port number. So typing the virtualhost name in URL search bar allows you to quickly link to the ip and port following it.

In addition to specifying that in the docker run, the vim/vi /etc/hosts file must be modified to contain the port and the ip address you want to link aliases to. Personally this seems inefficient as i would rather just want to have docker set its containers specifications up instead of myself. None the less, the format of IP's and ports in this are as follows...

IP ADDRESS   alias1 alias2 alias3 alias4...
::PORT   aliasToPort
::PORT   2ndAliasToPort

So for a specific IP address, it may accept a variety of alias's and can be further specified which port to access a specific alias from.

So to recap, docker must be ran as docker run --env=VIRTUAL_HOST=*alias* --env=VIRTUAL_PORT=*port* -p *IP*:*port*:*ContainerPort* *image* for any container you wished to be ran off docker contained nginx server. And the vim/vi file of /etc/hosts must be typed as

*IP*   *alias*
::*PORT*   *aliasToPort*
1
  • I must not be doing something right if i keep answering my own questions before anyone else can...
    – Jouster500
    Jul 15, 2015 at 13:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .