Docker basic commands

Docker creates lightweight unique virtual machine, called containers, on your machine. These containers differ from the tradition VM like VirtualBox in a way that all containers shares the same host operating system instead of each virtual machine having it’s own operating system.

A container is running instance of docker image.

Task Command
List all containers docker ps -a
List all containers’ ID docker ps -a -q
List all active containers’ name docker inspect -f $(docker ps -q)
List all docker images on current machine docker images
List all docker images ID docker images -q
List all docker volumes docker volume ls
Delete all docker images docker rmi $(docker images -q)
Delete all docker containers docker rm $(docker ps -a -q)
Delete all dangling volumes docker volume rm $(docker volume ls -f dangling=true -q)
Delete all dangling images docker rmi $(docker images -f dangling=true -q)
Show docker stats with Container names instead of ID docker stats $(docker ps –format={{.Names}})
Copy all files in src directory to dest directory docker cp /Users/host/src/. cont1:/home/container/dest
Create new src directory in dest directory docker cp /Users/host/src cont1:/home/container/dest
Delete all empty directories find . -type d -depth -print| xargs rmdir
find . -type d -empty | xargs rmdir
Read more

Hello Big Data

I’ve a big news to share today. After a successful and rewardful journey with OSIsoft, I’ve moved to Silicon Valley. I had great opportunities to learn and grow at OSI and believe that it’s a unique committed organization with its people being a huge asset.

A quick highlight of my time at OSIsoft

Read more

Clone an Object with Closures

Background: Object with closure properties

Closure properties can be thought of as a non-persistent property e.g. a web-page with thumbnail of cars and user selects a car with mouse click. Let’s say we have a isSelected closure property.

Read more

JavaScript Data Type Visualizer

JavaScript is a powerful but infamous language. Why JS is notorious [link: Wat]. Personally, I find data types confusing for someone coming from C#, Java world.

I build a small utility to visualize relationship between different data types and their prototype chain.
JavaScript Type Visualizer:

Read more

First work anniversary

This June, I completed my first year at OSIsoft and it’s been a remarkable experience so far. For the past one year, I was not contributing much on my blog However, I was working on learning JavaScript, which I now believe is a pretty good language and would be the primary focus of this blog.

It’s time to step back and look what all accomplished in past one year:

Read more

Learning JavaScript


  1. Focus on basics first. Instead of learning new *.JS framework, learn JavaScript language.
  2. Read books. Internet is great, but not everything written on Internet is correct. I prefer to read online once I am good with fundamentals.
  3. Play with browser developer tools as much as you can.

Recommended books

Read more

Creating JavaScript objects

There are three ways to create objects in Javascript.

Object literal: Easiest and cleanest way to create “one” object. However, Somewhat complex to add functions on prototype.

var foo = { name: "default", age: 25 };

Constructor: Use it if you want to create multiple objects of same type and need more control over the prototype chain.

Read more

Extracting 'n' least significant digits

A simple Javascript helper function to extract 2 least significant digits from a number. E.g.

98314 -> 14,  
4 -> 04,  
1998 -> 98
Read more

Default sorting in JavaScript

I was wondering about the default sorting technique used in Array’s sort() method and turns out it is Insertion Sort.

More important is to understand how easy it is to answer these trivial questions using Chrome developer tools.

Read more

Software Security notes

XML Entity Expansion

Create a foo.txt file in your C: directory and try to parse the following XML. The result is what you call XML Entity Expansion vulnerability.

<!ENTITY fooFromFile SYSTEM "c:\foo.txt">

<!ENTITY first "hello">
<!ENTITY second " world">
<!ENTITY attack "&first; &second;">
] >
<statement>&fooFromFile; &attack;</statement>
Read more