Docker is a topic, which can be difficult to understand if you are not an Application/Software developer. I will try to make you understand “What is Docker and How to Install Docker on Windows” in an easy manner, even if you are a novice player in this ground.
Table of Contents
- 1 What is Docker and who created Docker
- 2 How Docker works
- 3 why Docker is used – use cases
- 4 what is Docker containerization
- 5 What is Docker compose, Docker Swarm and Kubernetes
- 6 Install Docker on Windows – Step by Step
- 7 Un-install Docker from Windows
- 8 Why Docker is bad and should not be used?
- 9 Video Tutorial
- 10 Conclusion
What is Docker and who created Docker
Docker is a leading software program for building applications based on containers and launched in 2013 as an open-source project by Solomon hykes (Founder of Docker).
Containers can be treated as (boxes) which allows developers to deploy an application with all dependencies and libraries in a single package and it’s isolated to another application environment but uses the same operating system kernel.
Generally, there are four phases of the software development lifecycle Design, Develop, Deployment and testing/release. Docker comes at the deployment phase.
If you have used any software in your life, I bet you have faced this issue sometimes in your life. That software code is working on one platform, while it’s not working on others due to compatibility issues.
Software is a complete stack of Frontend, backend components, Database and library dependencies. It is really a nightmare for developers to make every software compatible with all hardware and operating system.
The classic example of the shipping industry
A very old problem of the shipping industry relates to it, where transportation of goods of different size, shape and requirement to a different location of the world, was really a challenge.
They resolve this using ‘”Big Containers“, so if you are a businessman and you want to ship your product to rest of the world, you just need to wrap it as per container standards, then you don’t need to worry about its shipping method.
Now your product can be shipped via water or air, doesn’t matter as it is in the container and compatible with all modes of transportation.
Same applies to software, now Developer’s just need to make a package of all components and dependent libraries of software and it can be shipped/deployed using Containers, Docker resolves this basic problem of developers.
if you will ever see Docker’s logo “Moby Dock” in future, you will relate all the above-mentioned theory, “where a whale is shipping containers using water transport mode”
How Docker works
Docker is based on a client-server architecture and contains below-mentioned components
- Docker Client
- Docker server (Daemon)
- Docker Hub/Registry
- Docker image
- Docker run
- Docker Engine
- Docker containers
As mentioned earlier, Docker is a client-server architecture mainly composed of Client, Docker daemon and Registry. Docker client can communicate to local or remote Docker daemon using Rest APIs, over Unix socket and network interface.
Docker client (docker) is the primary way to connect Docker server or daemon locally (if client and server installed on the same server) or remotely. Docker client sends commands like “Docker run” using Docker API to Docker daemon which carries them out. Docker client can communicate with multiple Daemons.
Docker server (Daemon)
It is the core of Docker’s architecture and responsible for heavy lifting tasks like building, running and then the distribution of Docker containers. The Docker daemon (dockerd) listens for client APIs requests and manages all containers, images, volumes and networks.
Docker Hub is a public registry (repository) store all Docker images and it can be used by anyone. you can have your private Docker registry also. By default, Docker is configured to look for images in Docker hub but you can point it to your private registry too.
“docker pull” fetch images and “docker push” push images to configured registry either public or private.
Dockerfile is a text document that contains all the instructions and syntax to build images. Docker daemon runs each instruction mentioned in dockerfile one by one and commits the result to build images.
is a read-only template that contains the instructions to run an application as a container, such as config files, code, environment variables, dependent libraries and runtime.
Command-line utility to launch your container, every container is an instance of an image.
$ docker run -i -t "image name" /bin/bash
Whenever you say, docker, it refers to Docker engine (DE), if you combine client and server functionality in a single block shown in Docker architecture diagram, that is “Docker engine“. Docker engine enterprise and Docker engine community are the two distribution of Docker engine.
Containers are executable or runnable instance of applications created using Docker images. CLI or APIs can help to create or delete containers. Containers are isolated from each other but shares same operating system. containers can attach storage, can be connected to more than one network and even can create new images.
why Docker is used – use cases
Docker containers actually encapsulate everything an application requires to run, gives us the flexibility to deploy it on any platform whether it’s a private pc/laptop or a cloud VM. Below mentioned are few but not limited use cases of Docker
Standardization:- Docker makes an application lightweight, portable and easy to deploy. Addition to this Docker is shaking hands with other container powers like Redhat, Google, and parallels for its key component libcontainer, which will help to standardize containers across all technologies and vendors.
CI/CD management:- continuous integration (CI) and continuous deployment (CD) are the backbones of today’s DevOps environment. An application code travels from developer’s workstations to production environment by facing many in-between environments like Dev, Test and pre-prod. Each of these may have some minor differences or changes.
Docker eases the code development and deployment by providing a consistent environment for the application from development to production. Changeless nature of Docker images and ease to deploy and spun up helps to achieve zero change in application runtime across environments.
Developer’s boon:- “This code works on my machine” is really a nightmare for software developers. In a software development life cycle, the trickiest part for a software developer is to deal with environment disparity across different hardware and platform.
Docker helps to run containers locally without worrying about platform or hardware. Developers don’t need to install software or application packages locally, anything required to develop software can run on Docker engine as container regardless of the language or the tool.
APP isolation:- Containers allow running the application in isolation. which means more than one application instance can run on a single operating system and none of these will interfere with each other.
Quick deployment:- Docker containers are easy to create and can be up and running in milliseconds. This is achieved as the only application process is running under docker and there is no operating system boot involved.
Infrastructure consolidation:- One of the major advantage and use case for business in my view. Traditionally application is installed on the operating system. Due to this, Servers or Virtual machine count increases as per your application instances.
Docker container helps to consolidate these servers or VMs by hosting more than one application and utilizing resources of the same server and operating system. It also helps to save the cost of the OS licenses.
what is Docker containerization
In this section, I will try to differentiate between containerization vs virtualization, Because most of the readers may have confusion around this initially, like me.
Docker containerization is based on the OS (operating system) kernel-based virtualization. It creates multiple virtual units in userspace a.k.a containers through private namespace and resource control mechanism.
It provides a different kind of abstraction in terms of virtualization when compared to Hypvervisors.
let me explain you with a diagram –
Left side block depicts Containerization and right side for virtualization. Now you can easily differentiate that Virtualization involves one extra layer of bare metal hypervisor compared to containerization.
Many times, a question asked whether Containers are like virtual machines?, So the answer is no because docker container moves up the abstraction from the hardware level to the operating system level.
it also avoids overhead on hardware which occurs due to “hypervisor layer” hosting Virtual machines and it’s drivers. Docker containers are portable, lightweight, infrastructure isolated and built for self-contained microservices.
But Can you install Docker engine on Virtual machines? The answer is “Yes”, whether your VM exists in your Datacenter or in the public cloud like Google, Azure or AWS. Containers are really easy to deploy and manage from anywhere.
What is Docker compose, Docker Swarm and Kubernetes
if you are managing a few instances of Docker containers, then it would be easy to manage it on Docker engine. But if you are managing a large environment, you can’t live without these purpose-built deployments and orchestration tools for containers –
Compose is a tool to manage multi-container Docker applications, it simplifies process and development of multi-container applications. using a YAML file, you can define what all services will be included in the application. Then single command can start or even can create all services defined in your configuration file.
You can configure dependent services, define nodes and storage using Docker compose commands in simple three steps
- Define your app environment in “dockerfile” to reproduced anytime and anywhere
- Define all services in “YAML” file, so that they can run together in an isolated environment without any hassle
- Run “docker-compose up” command and run your entire app.
Common use cases of Docker Compose are –
- Ease of creating a Development environment
- Automated testing of environment
- Single host deployments
Basically cluster of Docker engine is known as Swarm. Docker swarm is a native tool of Docker, which provide an advance level of orchestration to handle and manage multiple containers deployed across multiple hosts.
You can use Docker swarm to manage Swarm (Clusters), deploy application services to swarm and manage Swarm behaviour in your environment.
Check out more feature highlights on Docker swarm
Kubernetes is also one of the opensource orchestration software to automate deployment, scaling and management of containerized applications. Most of the developers like to manage their containerized environment using Kubernetes due to below-mentioned features –
- Service discovery and load balancing
- Storage orchestration
- Automated rollout and rollbacks
- IPV4/IPV6 dual stack
- Batch Execution
- Horizontal scaling and many more.
Install Docker on Windows – Step by Step
The community version of Docker desktop is available to install in windows 10.
Download Docker desktop from Docker hub.
Double-click Docker Desktop Installer.exe to run the wizard
Follow the installation instruction on the wizard and restart your machine
Add your account to the docker-user group, if required
Login with your Docker id and Enjoy your first container in Docker.
Pre-requisite to know before Docker installation
- Windows 10 64 bit Pro, education or Enterprise (build 16299 or later). Docker can be installed on Windows home using WSL2, check out my post to install wsl2 on Windows 10.
- Hyper-V and container feature must be enabled
- at least 4GB RAM, 64-bit processor (SLAT), virtualization enabled in Bios.
- Signup for Docker user id on Docker.com
Check your Windows version, press “Windows key + R” and type “winver“.
Visit the Docker website to download “Docker desktop” for windows.
once download finishes, visit your “Download directory” and Double-click “Docker Desktop Installer.exe” to install Docker desktop on windows.
Follow the installation instruction on the wizard and make sure “Enable WSL2 Windows feature” is selected.
once the installation is successful, restart your machine
Add your user account to the “docker-user group”, if you are not using the same admin account.
Press “Windows key + R” and then type “lusrmgr.msc”. visit groups and then “docker-group“, add your user to this group
Double click on “Docker Desktop icon” on your desktop and it will start the “Linux container WSL2 backend service“.
Click on Start, once getting started window of docker appears.
Then click on “Skip tutorial”
Signup for “Docker user-id” on Docker.com, if not already done. You can find the user icon on the “top” of the Docker window. This step is necessary to download the “getting-started image” from Docker-hub, otherwise, the command may fail.
Now copy command which is visible on “Docker window”
docker run -d -p 80:80 docker/getting-started
and paste it in command prompt to run your first container.
It will download the default getting-started image from Docker hub. Enjoy your first Docker container.
Un-install Docker from Windows
- Select Settings > Apps > Apps & features from windows start menu
- Select Docker Desktop and click uninstall
- Confirm your selection
Uninstalling Docker desktop is really easy, it’s like any other software to uninstall.
Select Settings > Apps > Apps & features from windows start menu
Select Docker Desktop and click uninstall docker on the Windows 10.
Validate Un-installation is successful.
Why Docker is bad and should not be used?
We talked about many good things about Docker but it’s not a one-stop solution for everything and has its own limitations. Below mentioned are few of them
If you need speed and performance
Docker containers are small in size compared to Virtual machine and use fewer resources. Docker may result in speed reduction due to shared OS kernel and resources, compared to dedicated resource assignment for application and DB in case of VMs.
Also if you have not setup CPU, memory and Block IO limits on Docker, OS kernel can kill important processes to save low memory crisis. if it’s your Docker process, unfortunately, then it may result in crashing your application or DB.
If you want to prioritize security
Any malicious code in the application can get access to your memory, as all Docker container uses the shared memory of hardware. If recommended practices are not followed in downloading Docker images, applications and container isolation. It may break your environment and result in downtime of critical applications.
If your application is desktop GUI application
Docker is mainly designed for console-based application which is not rich UI (user interface). Due to Windows container’s nano and core server technology, it doesn’t allow users to start GUI or use RDP (Remote desktop) services. Although it can be achieved by X11 forwarding technique.
Linux containers can run or support a GUI based application developed in QT and python framework.
if you want to use different OS and kernels
Docker image requires the same operating system, it was built for. For example, if you have downloaded an image from the Docker hub, which was created using Ubuntu as an operating system, then it will run on ubuntu only.
If you have a lot of important and valuable data to store
Data inside the container will be lost once, it is shutdown. So if you have important data inside a Container, you have to figure out ways to copy this to a different location. Moving your data out of a writeable layer of Container is not easy, it can be achieved by tools like “Docker data volumes” which may be hectic and clumsy sometimes, so you need to plan for backup of your valuable data cautiously.
video on “How to Install Docker in Windows in 2020”
I have tried to cover all aspects of Docker and it’s associated terminologies so that if you will land on my post, you will have a fair idea of game-changing Docker.
I hope, now Docker is no more an alien concept for you and I was able to deliver it, in an easy and simple manner.
If you are satisfied and able to understand Docker after reading this post on “What is Docker and How to Install Docker on Windows“, share it and if you don’t like it, Comment and let me your feedback.
Thanks for your time… see you soon in the next post.
Till that time take care and be healthy.