Tuesday, August 11, 2015

Public access to docker container

Let's say docker container running some application along with ssh daemon is launched on base dockerhost (could be Linux, CoreOS etc VMs).

Now you are inside docker container and you need to know the port of external host to which container's ssh port is mapped.

This query should give you the result:

curl -s http://$(route | grep default | awk '{print $2}'):4243/containers/json | grep $(hostname) | awk -F":" '{$NF=$(NF-1)=""; print $0}'| awk '{print $NF}'| awk -F"," '{print $1}'

Please note that docker host name is not hardcoded in the query. It is derived from network configuration of container itself. 

Tuesday, February 24, 2015

Git Submodule Tutorial


Requirement: Automation run needs code from framework repository which is maintained independently. How do we ensure that we also get framework code whenever we clone/update product automation code.

Solution: Make “framework” a submodule of “automation”

Framework: https://stashserver/stash/scm/abc/framework.git

Automation: https://stashserver/stash/scm/ta/automation.git

Task 1: Add submodule



 git clone -c http.sslVerify=false clone https://stashserver/stash/scm/ta/automation.git

 git submodule add https://stashserver/stash/scm/abc/framework.git

 git commit –m “Add submodule named framework”

 git push origin master

Task 2: Clone automation code repository which includes submodule



 git clone --recursive https://stashserver/stash/scm/ta/automation.git

Task 3: Get latest contents for automation project and framework submodule in an already cloned repository



 cd automation_project_dir

 git pull --recurse-submodules

 git submodule update

Task 4: Update the revision of framework repository which is being referred to by automation repositories



 cd automation_project_dir

 git submodule update --remote framework

 git add framework

 git push origin master