Docker Tutorial for Beginners | What is Docker?

Neeraj Moudgil
4 min readSep 17, 2019

--

docker
docker

Hello! everyone. In this tutorial series, we will be learning Docker from beginners’ perspective. We will be focusing on docker definition, docker images, containers, common docker operations and Dockerfile.

There is no prerequisite for learning docker. Docker will help you to ship your app to production/operations team without any failure. Before starting let’s look at why we need Docker at first place.

Docker in Layman’s Terms

Imagine you have a plant, which specifically grows in the region where you are staying, suiting all the weather and soil conditions. Now, when you gift the same plant to one of friends staying at far away city and when he tries to plant it, it didn’t grow as expected. What could be the possible reason? You guessed it right! — Change of surroundings/environment. One thinkable solution to this is designing a smart box or container with similar soil and which maintains specific light and humidity inside itself. If same thing you apply technically you will get to know main purpose of containerisation or docker usage.

Problems Before Docker

Imagine you are a developer and building a Django Web app. You are building it over a machine with specific OS. Other requirements are Python, Django ,Other dependencies/libs. Now when you are running your app locally with all the dependencies with specific versions, it is working fine, but when you ship the code to operations team to test, it is failing, even when ops team tried their best judgement to replicate the environment.

There could be couple of reasons of failing the build, one of them could be different version of libs/dependencies installed by ops team.

One of the solution we were following before docker existed is by using VM (Virtual Machines). Problem with VMs is that are very large in size and when you have different VMs with different requirements or versions it becomes complex for operations team for maintaining different staging, development and production environments. To save us from all this hectic process we have Docker.

What is Docker?

Docker is a computer program that performs operating-system level virtualisation. It was released in 2013 by Docker, inc. It is used to run software packages called containers.

Your containers are easily portable wrapper around your software and using same wrapper you can make deployment to different environments quickly and efficiently. Size of container is one of the main advantage of docker over VMs. An alpine container can be as small as 50Mb.

Docker Architecture

docker architecture

Hardware is your machine

Operating system is the OS installed over your machine

Docker Engine is the docker software you need to install to work with docker. It manages all the containers, images and operations related to it. You can install docker software by visiting Docker install for your specific OS.

Image is a virtual wrapper around your app. You can keep your app code inside the image.

Container - You run the image inside a Container. For example if you need Ubuntu required for your app, you just need to rundocker run ubuntu. Docker engine will automatically pull the Ubuntu image from docker hub and run it for you inside the container. Container can be in running state, stop state or deleted state.

You can use different containers for different purposes for example you can create one container for your front-end, one for back-end, one for database etc. based on your requirements.

Docker hub is the central repository where you can pull push images similar to Git hub repository. You need to signup with docker hub to create public or private repositories. There are already many open source images existing on docker hub which you can directly pull and run in local container.

Why the container size is not big even when you are running ubuntu — an OS image?

As you can see the architecture image — container shares the underline kernel of the OS installed on your machine, it only has the minimum libraries/bins required to run the ubuntu image.

This also defines the major difference between docker and VM i.e. in VMs every VM will have it’s own guest OS over the existing machine’s OS which results in bigger size of VMs. On other side docker shares the machine’s OS and need minimum bins/libs resulting in small size containers.

What’s Next?

We will look at common docker operations and run our first container. Happy Learning!

Thanks for reading. If you find the post helpful, cheer me with claps. Spread and help others learn. You can get in touch over linkedin.

--

--