Docker Tutorial

Docker Tutorial

We hope this docker tutorial will help you to understand some more details about docker and its usage.

Docker, the word itself gives the whole meaning of the docker system. We know that it is difficult to clone a specific configuration to somewhere else. The docker makes this very simple. Build, Ship, Run!!! Exact definition for docker. Docker is an open source platform for building, shipping and running distributed applications. The docker can make your application separate from your infrastructure and can consider your infrastructure as a managed application. It is speed and reducing the time between coding and executing makes docker successful.

Understand Architecture

As we have said already in this docker tutorial, the docker improves the speed of implementation. This is achieved by combining lightweight virtualization platform with workflows and tooling which helps you to deploy applications.The isolation and security are the main features of docker system. The lightweight nature of containers, which run without the extra load of a hypervisor, means you can get more out of your hardware. Surrounding the container virtualization are tooling and a platform which can help you in several ways:

  1. Dockerize your application and components moreover the whole infrastructure .
  1. Docker can be distributed to other teams for testing and development.
  1. Deployment of application irrespective of node platform.


Why should we use Container virtualization?

The development lifecycle can be easily completed using Docker. Docker allows your developers to develop on local containers that contain your applications and services. It can then integrate into a continuous integration and deployment workflow.

Docker’s architecture!

  1. Docker daemon

This is something which runs on the node machine. User can interact with daemon using docker client.

  1. Docker Client

It is the user interface of docker. It act as the communication link between the user and daemon.

  1. What’s inside Docker ?


Docker images.

A Docker image is a read-only template. For example, an image could contain an Ubuntu operating system with Apache and your web application installed. Images are used to create Docker containers. Docker provides a simple way to build new images or update existing images, or you can download Docker images that other people have already created. Docker images are the build component of Docker.

Docker registries.

Docker registries hold images. These are public or private stores from which you upload or download images. The public Docker registry is called Docker Hub. It provides a huge collection of existing images for your use. These can be images you create yourself or you can use images that others have previously created. Docker registries are the distribution component of Docker.

Docker containers.

Docker containers are similar to a directory. A Docker container holds everything that is needed for an application to run. Each container is created from a Docker image. Docker containers can be run, started, stopped, moved, and deleted. Each container is an isolated and secure application platform. Docker containers are the run component of Docker.

Exploring working.

The docker container is created from read-only templates. Each image consists of a series of layers. Docker makes use of union file systems to combine these layers into a single image. Union file systems allow files and directories of separate file systems, known as branches, to be transparently overlaid, forming a single coherent file system. While creating a docker container we can either use templates which are downloaded already or directly pull while running it. There are wide variety of option which can be used while creating a container. The options like binding a port, defining interactive , tty, container name, Once created we can attach the docker container.

The underlying technology


Docker takes advantage of a technology called namespaces to provide the isolated workspace we call the container. When you run a container, Docker creates a set of namespaces for that container.

This provides a layer of isolation: each aspect of a container runs in its own namespace and does not have access outside it.

Some of the namespaces that Docker uses are:

The pid namespace: Used for process isolation (PID: Process ID).

The net namespace: Used for managing network interfaces (NET: Networking).

The ipc namespace: Used for managing access to IPC resources (IPC: InterProcess Communication).

The mnt namespace: Used for managing mount-points (MNT: Mount).

The uts namespace: Used for isolating kernel and version identifiers. (UTS: Unix Timesharing System).

Control groups

Docker also makes use of another technology called cgroups or control groups. A key to running applications in isolation is to have them only use the resources you want. This ensures containers are good multi-tenant citizens on a host. Control groups allow Docker to share available hardware resources to containers and, if required, set up limits and constraints. For example, limiting the memory available to a specific container.

Union file systems

Union file systems, or UnionFS, are file systems that operate by creating layers, making them very lightweight and fast. Docker uses union file systems to provide the building blocks for containers. Docker can make use of several union file system variants including: AUFS, btrfs, vfs, and DeviceMapper.

Container format

Docker combines these components into a wrapper we call a container format. The default container format is called libcontainer. Docker also supports traditional Linux containers using LXC. In the future, Docker may support other container formats, for example, by integrating with BSD Jails or Solaris Zones.


The docker can be installed using Yum on Centos and apt-get on Ubuntu. Just need to add corresponding sources/repos.

Managing docker

We can start and stop the docker service using commands as follows.

start docker

stop docker

The docker system is accessible only when the service is running.

Docker Images

Docker hub provides predefined images which can be used for creating containers.

docker search <image_name> # search for an image from docker hub

and docker pull <image_name> pull the image from docker hub


docker search ubuntu

docker pull ubuntu

Note: Please read the description completely before downloading images. It is recommended to download images with high star count and ‘OK’ OFFICIAL status.

Container Creation

We can create a docker container as follows

docker run -i -t –name <container_name> <image_name> <process/tty>

# -i interactive

# -t specify tty

E.g. :: Creating a docker container with ubuntu image

docker run -i -t –name testcontainer ubuntu /bin/bash

This command will create a docker container with interactive mode. Use Ctrl+p+q to exit from the container without killing the process

Port binding and Ip assignment.

The ports actually bind to a specific port of the node server. The connections to a port to a corresponding IP in the node is routed to a specific port in the container. In this way the connections to the port of the node to the IP will be directed to the specific port on the container. We route port ranges between the docker container and an IP (provided the services in node server with the corresponding ports are listening only to the main IP address of the server.


docker run -i -t –name -p <IP>:<node_port>:<container_port> <container_name> <image_name> <process/tty>

Note:: For all following examples, we use and as additional IPs in the docker node

E.g. 1 ::

docker run -i -t -p -p -p –name custom_name centos/ssh /bin/bash


IP:Node Port:Container Port

E.g. 2 ::

docker run -i -t -p –name portmap ubuntu /bin/bash

This will map ports 20 to 50 between the docker container and the IP ‘’

  1. Miscellaneous

docker images #: to list docker images

docker save <image_name> > <backup_name>.tar # backup an image

docker load -i <backup_name>.tar # load a saved image

docker ps # to show running docker containers

docker ps -a # to show all containers including stopped ones

docker rm -f <container name> # to delete a container

docker rmi <delete a image> # to delete a image

docker start <container name> # to start container

docker attach <id/name> # to attach a docker session

docker info # to get the information of docker server


Docker Tutorial Conclusion

The docker is the fundamental building block of distributed container deployments. It simplifyes the process of packing of application along with its components, scaling becomes a simple process of spinning up or shutting down multiple instances of each component. The Docker provides us with feature of sharing and management of containers.

While containerized applications provide the necessary process isolation and packaging to assist in deployment, there are many other components necessary to adequately manage and scale containers over a distributed cluster of hosts.

Hope this docker tutorial helped you to get some basic ideas about docker. If you have any questions about this docker tutorial please let us know.

Please share this docker tutorial knowledge.


Posts created 6

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Enjoy this blog? Please spread the word :)

Follow by Email
Visit Us
Follow Me