Understanding Docker for beginners

This is a guide to help getting a understanding of docker world when you are familiar with cloud, clusters, deployment, CI/CD, application, server etc.

So before learning docker, lets first understand what Image is

Image: Its a light-weight stand alone executable package. Its like .exe package for windows or .apk package for android. Like an apk file is stand-alone complete package in itself which runs on top of android, similarly image is independent package which runs on top of docker.

Like you are run multiple apps on android, similarly you can run multiple images on docker.

An Image includes everything needed to run that piece of software including code, libraries, environment variables, configuration.

This android analogy helps me get the feel of image.

Container: Runtime instance of image is container. What image becomes in memory when actually executed

You could have 100’s of images downloaded at your machine but only few of them could be running like android (See I told you, android analogy helps!!)

So back to docker. What is docker

Docker is a tool which run on top of your host machine’s OS (like a VM). Its like a layer on top of your OS.

Container runs on top of docker, hence they are isolated from host environment.

So a container will behave identical inspite of underlying OS whether you run on linux, OSX, No matter what your underlying system configuration is.

So if you want to share you application, simply create an Image and just share that image with anyone. You don’t have to worry about OS, environment variables, file system or anything. As long as docker is installed on that system.

Such isolation help development, management, testing and deployment.

Containers can access hosts file and ports if configured to do so.

This container diagram paints a really good picture (courtesy: official docker docs)


$ docker run hello-world

This command will run image named hello-world. Since this image is not present locally, docker will first pull (download) this image from docker hub repository.

run command will create a new container from this image which runs executables present in the image.

So now when you run

$ docker images

you will see hello world image present at your local

Run $ docker ps -a to see hello world container present