Docker for Rookie


If you are a rookie (new developer) then you are at the right place to know about the docker. Here at the end of this blog you will get a clear clarity on what docker is and how to get started. Before that, if you want to know how to install docker on windows 10 check the below video.

Once you installed the docker in your local / server we can run and test any applications like python, java, node, react and php etc. using the docker container images.

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Lets have a quick look on what is docker file, docker image and docker container with a simple illustrated process flow.

Here the docker file helps to build the source code and the required software into an intermediate form called docker image. Once the image is build, We can run it on any platforms having docker installed.

NOTE : Only the basic commands will be used in this blog for beginner's learning purpose, refer official docker  site for the full list of commands.

Docker FILE

  • A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. 
  • Docker can build images automatically by reading the instructions from a Dockerfile.
  • Example Dockerfile, if we want to run a static website on a nginx server.

Create a HTML file and save it as ‘index.html’

<title>Testing Docker</title>

<h1>First Docker Handson</h1>
<p>By Class Adviser</p>


Create a docker file and save it as ‘Dockerfile’

  FROM nginx:alpine
  COPY . /usr/share/nginx/html

There are many Docker commands available to do sequence of necessary steps for building the docker image, the very first thing is the FROM command which will download the base image. A base image is also a docker image which will have the necessary software to run the app.

In the above example, we are downloading the alpine version of nginx from the dockerhub repository using the FROM command. The second step is COPY command which is copying our source code into the target location of the base image. This two step will help us to copy our source index.html file into the /usr/share/nginx/html location and once we build the above docker file we will get our own docker image.

Docker Images

  • A Docker image includes the elements needed to run an application as a container such as code, config files, environment variables, libraries and run time
  • Docker images are also a reusable asset that can be deployed on any host.
  • Example for creating a docker image for static website
docker build -t html-sample:v1 Dockerfile

Above command will read the Dockerfile and build a docker image in the tag name html-sample with the version v1. This docker image will have the nginx server and the source code. To check the list of docker images available, try the below command.

docker images

This command will return all the available downloaded images in the machine / server, and those images can be run on the docker container.

Docker Containers

  • Container images become containers at runtime and in the case of Docker containers – images become containers when they run on Docker Engine.
  • Example, lets create a container for the static website using the docker command.
docker run -d -p 80:80 html-sample:v1

This command will run the docker image html-sample:v1 on the port 80 in the docker and the same port is exposed in the machine. To check the status of the running container use the below command.

docker ps

Once the container is running successfully open the browser and go to http://localhost:80 then you will able to see your html design running on the docker container as like below..

Thank for the time spent on the learning the docker basics, I hope you will have some understanding now on what is docker and how to run the docker image in the docker container. Please do post your thoughts and comments to connect with me.

1 Comment

By Mano

Get in touch

Let me know on Class room, if any topic which you looked out here is not available, I will make sure that will be there for you on next visit.