Getting started with Docker: Practical Introduction

Reading Time: 3 minutes

What is docker

Docker is a is a software containerization platform which packages our software application and all its dependencies into a single package in form of containers. It helps to run our application seamlessly in any environment such as development, testing or production. Docker assures that we don’t need to install dependencies again and again. it saves lots of time and energy. It also ensures that the working environment is same among all the individuals involved in team. The number of system can be scaled up easily and code can be deployed rapidly.

Why docker

Docker’s main advantages are:

  • Lightweight resource utilization:  It does not require to virtualize the whole OS as containers isolate at the process level and use the host’s kernel.
  • Portability:  All the dependencies can be bundled inside a container, which helps to run it on any docker host.Docker enables you to build a container image and use that same image across every step of the deployment process.
  • Faster configurations:  Users can take their own configuration, put it into code and deploy it without any problems. As Docker can be used in a wide variety of environments, the requirements of the infrastructure are no longer linked with the environment of the application.
  • Compatibility and maintainability:  Eliminate the “works only on my machine” problem once and for all. Docker images run the same no matter which server or whose laptop they are running on. For developers, this means less time spent setting up environments, debugging environment-specific issues, and a more portable and easy-to-set-up codebase.


It is just a text file which has all the instructions to build an docker-image of our application. We save this file named as “Dockerfile”. It includes all the instructions, dependencies, environment etc which are required to run our application.

Some of the instrunctions in a dockerfile are as follows-

  • ADD                    Copies a file from the local file system to the container file system
  • CMD                    The command that runs when the container starts
  • ENV                     Set the environment variable.
  • RUN                    It is used to run a command in container.
  • EXPOSE              It is used to set the ports for linking with other containers
  • FROM                 It is used to define the base image to run an application.
  • WORKDIR          Set the working directory for the container

Example of a dockerfile:

Here we simply define a Dockerfile to build an image of application which just shows the content of a text file on console-

FROM ubuntu:latest
RUN apt-get update
ADD textfiles/hello.text /
CMD [“cat”,”hello.txt”]

A docker-image can be build by running this command with the help of a Dockerfile

docker build -t image_name “path-to-dockerfile”


A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.

Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space. Containers take up less space than VMs (container images are typically tens of MBs in size), and start almost instantly.

Some of the Docker commands are as follows:-

//It is used to pull an image from dockerhub
docker pull image_name

//it shows all the existing docker images on system
docker images

//It is used to run the docker images
docker run –name container_ame image_name:tag

//It shows the logs of a conatiner
docker logs container-id/container-name

//it shows all the existing container on system
docker ps -a

//it shows all the running container on system
docker ps

//It is used to insert into a container environment
docker exec -it container_name

//It stops a running container
docker stop container-id/container-name

//It starts a stopped container
docker start container-id/container-name




Written by 

Himanshu is a Software Consultant with more than 1.5 years of experience. He is familiar with Object Oriented Programming Paradigms. He developed his own stand alone application in PHP for finding the details and location of stores, resturants, Hospitals, Schools, Colleges with help of google maps during his Master's Degree. His hobbies are travelling, watching news, reading blogs etc.

1 thought on “Getting started with Docker: Practical Introduction3 min read

Comments are closed.