Category Archives: Review

Getting Started with Docker

Docker logo horizontal spacing

Docker Allows you to run tiny containers inside your linux machine . These containers can be compared to Virtual Machines, but there are some differences that makes them easy and portable. In a user perspective, they are damn fast to start (and kill) compared to VMs and also very portable. I am trying to describe how to install and run containers with Docker on a ubuntu 14 ( trusty) machine.

Installation

Installation is fairly easy with the follwing command. It will ask your sudo password when needed.

wget -qO- https://get.docker.com/ | sh

It adds a apt repo and does the installation of the latest docker version on your machine. Verify the installation by running ‘docker -v’ command. It will show you the version of docker installed.

Pull and Run

Now, we need to pull a basic container and run it to see the magic.

$docker pull ubuntu:14.04
14.04: Pulling from ubuntu
e9e06b06e14c: Extracting [=======================> ] 62.95 MB/65.77 MB
a82efea989f9: Download complete 
37bea4ee0c81: Download complete 
......
$docker run -ti ubuntu:14.04 /bin/bash
root@c419ad172b0f:/#

What has happened just now is that you have downloaded the latest docker ubuntu 14.04 image from the docker registry and ran it. The ‘root@c419ad172b0f#’ prompt you see is the container running the bash shell. You can now work on it as you would in any other normal ubuntu machine, when you exit the shell, it would stop the container as well.  Enjoy !

Maintenance

Everytime you exit a container, it does not actually delete it. It is left in the filesystem so that you can restart it if needed. Let’s take a look at how we can see the images we pulled, and see the containers we started and also how to work with them.

$docker images
REPOSITORY                                           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu                                               14.04               07f8e8c5e660        2 weeks ago         188.3 MB

As you can see, it lists all images you have downloaded from internet. To remove a image , run ‘docker rmi ubuntu:14.04’

$docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c419ad172b0f ubuntu:14.04 "/bin/bash" 24 minutes ago Exited (0) 2 minutes ago hopeful_thing

This is the container that just got stopped in the previous step. Notice the CONTAINER_ID c419ad172b0f is the same as the hostname of the container we had when we ran the first container. Each time you start a container , it creates a unique ID . You can start a stopped container and attach shell to it using the commands below.

$docker start c419ad172b0f
c419ad172b0f
$docker attach c419ad172b0f
root@c419ad172b0f:/# echo Hello
Hello
root@c419ad172b0f:/# exit
exit
$

Now let’s take a look at how to remove a container.

$docker rm c419ad172b0f

Customized Images

You can also create customized images for your use. For example, I want to have a image that includes ‘screen’ package on top of the basic ubuntu image.  It is easy to prepare a ‘Dockerfile’ and let docker create (build) a new image for you. Create a file named ‘Dockerfile’ inside a empty folder. Content is given below.

FROM ubuntu:14.04
MAINTAINER ksraju007@gmail.com

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update ; apt-get -y install screen ;
CMD "/bin/bash"

Now build the image. Notice that we are giving it a new name called u14screen using the -t option.

docker build -t u14screen --rm .
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu:14.04 
 ---> 07f8e8c5e660
Step 1 : MAINTAINER ksraju007@gmail.com
 ---> Using cache
 ---> 52fe481915f0
Step 2 : ENV DEBIAN_FRONTEND noninteractive
 ---> Running in 7d802e182f91
 ---> ffd0cd910a16
Removing intermediate container 7d802e182f91
Step 3 : RUN apt-get update ; apt-get -y install screen ;
 ---> Running in 6574afc3a441
....
Processing triggers for ureadahead (0.100.0-16) ...
 ---> 76433af5559b
Removing intermediate container 6574afc3a441
Step 4 : CMD "/bin/bash"
 ---> Running in 8933a2b86e12
 ---> ce468a62539a
Removing intermediate container 8933a2b86e12
Successfully built ce468a62539a
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
u14screen latest ce468a62539a About a minute ago 210.9 MB

Hurray ! You have just built your own docker image. Try running it.

$docker run -ti u14screen
root@95d2c547e113:/# screen -v
Screen version 4.01.00devel (GNU) 2-May-06
root@95d2c547e113:/# exit
exit
$

Since we have mentioned the CMD parameter in Dockerfile to start /bin/bash automatically, you do not need to specify that anymore during ‘docker run’ for your image. For more information about advanced docker options and Dockerfile parameters, see https://docs.docker.com/

The best thing about having Dockerfile is that now you can send the Dockerfile to your friends and they can build exactly the same image on their computer too. This makes it extremely easy to replicate work environments across people, not to mention that you are not copying lots of data too.. it is a simple text file.

Enjoy your docker experiments !  🙂

Weekend Project with OpenSource

Here’s another story about how open source helped me.

I have a USB disk at home where I store all my photos, videos, movies, songs etc.  The disk is connected to a desktop computer at home and shared across the network. Making it available on network helped me to backup my laptop data also to the disk using wireless connection. So far so good.

But what about watching movies or listening to songs or viewing pictures? I can do it from my laptop, but it will be only me. What’s the fun in that? I wanted to enjoy them with family and friends in my TV in the living room. Here’s how I did it.

In old Laptop, I installed PinGuy Linux (http://pinguy-os.sourceforge.net/ ) . I also updated all softwares to the latest version.

Now the problem is that I have a CRT TV. It supports only RCA input. My laptop had a  S-Video output. I bought a S-Video to RCA Cable and connected the laptop. It did not work !. Then I bought a VGA to RCA cable , that also failed. I did some research and ended up buying a VGA to RCA Converter box from the local electronics market. It gives 640×480 resolution that is probably the maximum my TV can do, anyways.. it worked.  🙂

Here’s the box.

So now, My TV shows only a part of the laptop screen because laptop is running at 1024×768 and TV can do only 640×480. Then I started XBMC , the Media Center Application. It gives a nice GUI to configure settings and also to manage the Media. I configured it to run in Window mode and dragged and re-sized the window to 640×480 resolution and placed it on the corner of the screen so that it covers fully what is shown on my TV.

Rest of the operation was simple, connected to my USB disk over network, added those files to XBMC. I also configured XBMC to show weather information and play Youtube videos.

I am now able to watch all my photos, videos and listen to songs in my USB disk via my TV. Hurray !

Wishlist :Infrared Remote for Laptop. Also a HD capable TV in future 🙂

Firefox 4 Released

Firefox 4 is now available for download. Click here to see what’s new.

I installed it on my laptop. It has improved a lot. Specially the way tabs are organized and the visual layout overall has been totally streamlined. It is also loading webpages faster. Unlike the previous versions, Firefox 4 is using less RAM on my system.

So what are you waiting for? Give it a try. 🙂

Performance review for Indians

Here is what I would rate from a totally negative manager’s point of view. I guess most of the people would agree with me.

People : We don’t care about others. Common mentality here is  “As long as my work is getting done, I will bribe, cheat, bend laws in order to get it”.  We want to know shortcuts for everything. We don’t like paying tips, but we do like receiving them. When we have problems, we will accuse the “system”. When they see a person is bleeding on the road, they will still walk away, after taking a picture on their mobile !.

Politicians :They are busy with securing a good future for themselves and their family. They have expertise in hiding money in foreign accounts. They go to USA for studying problems of people in India. Right will blame the left, and left will blame USA!

Media : They are supposed to report news as it happens. They will do anything but. dot.

Bureaucrats :They don’t consider people as people. For them, we are some worthless animals wasting their time. If you do not know any politicians or friends/relatives of these people, you have no voice, no choice but to bend your knees and lick their feet.

Managers : They think that we are slaves to them. Some of them even talk like they are the company, they will do good to their chamchas, they decide your future. What the heck.

Religions : They are busy in executing their agendas. Long time back they stopped reading what the Holy book ( be it Gita, Bible or Quran ) says. And even educated people are blindly following the blunders their leaders are making such as Jihad, Conversions etc.

Hospitals : No Doctor tells you the truth. You end up doing all kind of tests worth thousands even if what you have is just a fever. Medicines are sold at 200% profit . They might remove your Kidney when you go for doing surgery for appendicitis. Good luck.

Schools :Donations are sky high. We have different syllabus for different schools. So our children acquires different levels of knowledge  even though they are same age. Some get quality education and some end up getting nothing out of it even when they are going to school. Teachers are getting their jobs by paying bribes. How they will teach values to children?

As always, there are exceptions. Some people are there to help others, do their duty and work towards prosperity of everything. But unfortunately they are a rare breed and scarce to find.

Result : Improvement Needed.

P.S. : The common dialogue I hear regularly is “Why don’t you come to politics and improve it all ?” . Well my answer is : That does not mean that we cannot have an opinion. That’s just what I did now.  🙂