docker run hello-world

Virtualization is the latest Trend and it’s happening everywhere. We started with virtualising hardware and soon realised its over-kill. Realisation is the starting of change. It resulted in a light weight version of virtualization: Linux-Containers or LXC . They are getting adopted Industry wide.

LXC is the solution but what is the tool!!!

One of the most accepted tool is Docker

LXC makes use of the kernel functionalities of cgroup and kernel-namespace. It virtualises at the operating system level and makes it less costlier than its predecessor.

So let’s try setting-up docker and run hello-world, our very old custom..

fyi: Docker makes use of virtualbox. For OSX you may download the package (.pkg) from boot2docker/osx-installer and double-clicking it installs both virtualbox and docker. For other OS/platforms, you may follow instructions from docker-installation-guide.

Once the installation is complete, use splotligt (⌘-Space bar) to open boot2docker.

It opens terminal and runs the initialisation steps and generates encryption keys.

Screen Shot 2015-07-15 at 10.21.51 pm

The terminal is left to you after that.

Lets spin up the VM now.

boot2docker start

Display the docker environment variables to see if the certificate path are set right.

boot2docker shellinit

`To set the environment variables displayed with the above command, run the above command with ‘eval’

eval "$(boot2docker shellinit)" 
or 
$(boot2docker shellinit)

We are ready for the final run..

boot2docker run hello-world

You should now be seeing the output of hello-world.

Screen Shot 2015-07-15 at 10.45.51 pm

 

If things didn’t go well and you want to start again deleting the current vm, run the below set of commands in order.

boot2docker delete
boot2docker init
boot2docker start
$(boot2docker shellinit)
boot2docker run hello-world

Encrypt and Decrypt data using RSA with Openssl

What is RSA?

What is OpenSSL?

Generate private key:

  • openssl genrsa -out privatekey.pem 2048
  • openssl genrsa  // private key is written to stdout

Generate public key from the private key generated above:

  • openssl rsa -pubout -in privatekey.pem -out publickey.pem
  • openssl rsa -pubout  // copy paste the private key from the stdout; public key will be displayed on the screen

You must have your public and private keys in two files to continue. I have my public key in publickey.pem and private key in privatekey.pem and data to be encrypted in data.txt. Lets now encrypt and decrypt to check the correctness.

  • openssl rsautl -in data.txt -out encrypted_data.txt -inkey publickey.pem -encrypt -pubin

You will have encrypted_data.txt file created and you will see some wierd characters if you open it. Don’t worry, that is the exact purpose of encryption: make it not readable unless you decrypt with private key. So now lets use our private key to decrypt. Lets see if we get our original data back.

  • openssl rsautl -in encrypted_data.txt -out decrypted_data.txt  -inkey publickey.pem -encrypt -pubin

Compare data.txt and decrypted_data.txt and see the magic.. 😛

C++ build tool: boost bjam intro

Reference Material : HERE

Source code (hello_sree.cc):

Screen Shot 2014-02-26 at 2.56.26 PM

build file (jamroot.jam or Jamroot): Screen Shot 2014-02-26 at 7.00.22 PM

Now in terminal, change the present working directory to the folder where the code and build-file resides. Run any of the below commands:

Screen Shot 2014-02-26 at 7.01.05 PMORScreen Shot 2014-02-26 at 7.00.45 PMORScreen Shot 2014-02-26 at 7.01.52 PMORScreen Shot 2014-02-26 at 7.03.09 PM

Ensure you have a space between “hello_sree.cc” and “;” in the build file. Otherwise you will get the below error:Screen Shot 2014-02-26 at 7.03.23 PM

Screen Shot 2014-02-26 at 7.03.33 PM

You will get this message at the successful run:Screen Shot 2014-02-26 at 7.04.01 PMYou will see a bin folder with a hierarchy of folders and executable file created as part of successful build of our program