Quickstart – Docker for Beginners

docker logo

What is Docker?

Wow! That’s a mouthful. In simpler words, Docker is a tool that allows developers, sys-admins etc. to easily deploy their applications in a sandbox (called containers) to run on the host operating system i.e. Linux. The key benefit of Docker is that it allows users to package an application with all of its dependencies into a standardized unit for software development. Unlike virtual machines, containers do not have the high overhead and hence enable more efficient usage of the underlying system and resources.

What are containers?

The industry standard today is to use Virtual Machines (VMs) to run software applications. VMs run applications inside a guest Operating System, which runs on virtual hardware powered by the server’s host OS.

VMs are great at providing full process isolation for applications: there are very few ways a problem in the host operating system can affect the software running in the guest operating system, and vice-versa. But this isolation comes at great cost — the computational overhead spent virtualizing hardware for a guest OS to use is substantial.

Containers take a different approach: by leveraging the low-level mechanics of the host operating system, containers provide most of the isolation of virtual machines at a fraction of the computing power.


Goal of this Tutorial :

Here we are going to see Docker Installation, basic configuration, First image preparation with web application and few easy troubleshooting.

How to Install in Ubuntu 14: 04

Refer Install to see how to install different OS types, here going to see with Ubuntu

  • In Ubuntu
    sudo apt-get install docker.io

Check Version

sudo docker version

Pull an Ubuntu Trusty docker image

sudo docker pull ubuntu:14.04

Find Image repo in Dockerhub

After pulling ubuntu images, do list by

root@docker:/home/pandy# docker images

REPOSITORY  TAG          IMAGE ID             CREATED              VIRTUAL SIZE
ubuntu             14.04          a572fb20fc42     11 days ago              188 MB

Run a docker image, and execute command ‘echo “pandy”’ in the docker container created out of that image

sudo docker run ubuntu:14:04 echo “pandy”

Container information is stored in /var/lib/docker

If you run the above command multiple times, it will create a new container each time.

To know the ID of the last container, run

sudo docker ps -l

To list all the running containers

sudo docker ps

Note that the above command will not show the container we last run, because the container which we ran last time terminated just after it finished executing echo command.

Lets try differently

root@docker:/home/pandy# docker ps -a

8fc688183401 pandy/echo:latest “sh” 2 hours ago Exited (0) 2 hours ago agitated_fermat
22bf8556f207 hello-world:latest “/hello” 2 hours ago Exited (0) 2 hours ago clever_turing
0de9bfa9eab5 pandy/echo:latest “ls -ltrh” 3 hours ago Exited (0) 3 hours ago jovial_brown

The above command will show recent commands executed inside images and logoff period, Do notice that the STATUS column shows that these containers exited a few minutes ago.

Create a new docker image by name <yourname>/echo by ‘committing’ the last container which you ran

sudo docker commit <container ID> <yourname>/echo

Now running sudo docker images will list you two containers instead of one

Now you can run this new docker container like this:

sudo docker run <yourname>/echo ls -alrth

If we installed something, or created a file in the old container, it will be visible now in this container too.

Get more information about a docker image or a running container:

sudo docker inspect <yourname>/echo

To push docker image to docker repository

sudo docker push <yourname>/echo

To download ubuntu Trusty base image if not present locally, and open a shell session into it

sudo docker run -t -i ubuntu:14.04 /bin/bash

-i i.e. –interactive=false, keeps STDIN open even if not attached

-t i.e. –tty=false allocates a pseudo tty

Don’t worry what these mean. If you add these options, you’ll see that you already get logged in into the container shell, and the container only dies off once you exit from that session (usually by writing exit or pressing CTRL + D.

To remove an image:

sudo docker rmi <image name>


In the last section, we used a lot of Docker-specific jargon which might be confusing to some. So before we go further, let me clarify some terminology that is used frequently in the Docker ecosystem.

  • Images – The blueprints of our application which form the basis of containers. In the demo above, we used the docker pull command to download the busybox image.
  • Containers – Created from Docker images and run the actual application. We create a container using docker run which we did using the busybox image that we downloaded. A list of running containers can be seen using the docker pscommand.
  • Docker Daemon – The background service running on the host that manages building, running and distributing Docker containers. The daemon is the process that runs in the operation system to which clients talk to.
  • Docker Client – The command line tool that allows the user to interact with the daemon. More generally, there can be other forms of clients too – such as Kitematic which provide a GUI to the users.
  • Docker hub – A registry of Docker images. You can think of the registry as a directory of all available Docker images. If required, one can host their own Docker registries and can use them for pulling images.

Lets see in next blog how to build web application in docker container and use in cloud platform


One thought on “Quickstart – Docker for Beginners

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s