← Back to Articles         
What is Docker?

What is Docker?

Published on 04 Nov 2026 11 min read Docker
Docker Fundamentals

1. What is Docker?

Docker is an open-source platform used to build, package, and run applications inside lightweight environments called Containers.

A container includes everything an application needs to run, such as:

  • Application code

  • Required libraries

  • Dependencies

  • Runtime

  • Configuration

Simple Example:

Suppose you develop an ASP.NET Core Web API on your laptop. It works perfectly on your machine but fails on another server because the required .NET runtime or dependencies are missing.

Docker solves this problem by packaging the application and its dependencies into a container.

How Docker works

      ASP.NET Core Web API
                |
                v
          Docker Image
                |
                v
        Docker Container
                |
                v
         Runs Application

Why do we need Docker?

  1. Portability: Run applications on different machines.

  2. Consistency: Same application environment across development, testing and production.

  3. Isolation: Applications run independently without affecting each other.

  4. Easy Deployment: Deploy applications quickly.

  5. Scalability: Easily create multiple container instances.

Advantages

  • Lightweight compared to Virtual Machines.

  • Faster application startup.

  • Easy deployment.

  • Reduces environment-related issues.

  • Supports Microservices architecture.

Disadvantages

  • Requires learning Docker commands and concepts.

  • Container networking and storage can be complex.

  • Security needs proper configuration.

Real-World Example

You have three applications:

Docker Host
    |
    |-- Container 1: ASP.NET Core Web API
    |
    |-- Container 2: Angular Application
    |
    |-- Container 3: Redis Cache

All three applications run independently on the same Docker host.

Key Points

  • Docker Image: A packaged template used to create containers.

  • Docker Container: A running instance of an image.

  • Dockerfile: A file containing instructions to build a Docker image.

  • Docker Hub: An online repository to store and share Docker images.

  • Docker Engine: The software responsible for building and running containers.

     

 

2. What is the difference between Docker Image and Container?

Docker Image: A read-only template that contains application code, runtime, libraries, and dependencies required to run an application.

Docker Container: A running instance of a Docker Image. It provides an isolated environment to execute the application.

Simple Diagram

       Docker Image
       (Template)
            |
            | Create / Run
            v
       Docker Container
       (Running App)

One Docker Image can create multiple Containers.

          Docker Image
               |
       +-------+-------+
       |       |       |
       v       v       v
  Container  Container Container
      1          2        3

Key Differences

Docker Image

Docker Container

It is a template.

It is a running instance of an image.

Read-only.

Has a writable layer.

Cannot execute an application by itself.

Executes the application.

Used to create containers.

Created from an image.

Can create multiple containers.

Each container runs independently.

Real-World Example

Suppose you have an ASP.NET Core Web API.

  1. Create a Dockerfile.

  2. Build a Docker Image from the Dockerfile.

  3. Run the image to create a Container.

  4. Your Web API runs inside the container.

Key Points

  • Image = Template.

  • Container = Running application environment.

  • Multiple containers can be created from one image.

  • Changes inside a container do not modify the original image.

Interview Question

Can we create multiple containers from a single Docker Image?

Yes. We can create multiple independent containers from the same Docker Image. Each container runs in its own isolated environment.

 
 

3. What is Docker Hub?

Docker Hub is a cloud-based repository where developers can store, share, and download Docker Images.

Think of Docker Hub as GitHub for Docker Images.

Just as developers store and share source code on GitHub, they store and share Docker Images on Docker Hub.

Why do we need Docker Hub?

  • Store Images: Upload Docker Images to the cloud.

  • Share Images: Share images with other developers.

  • Download Images: Download existing images created by others.

  • Public Images: Access images available to everyone.

  • Private Images: Store images with restricted access.

How Docker Hub works

       Developer
           |
           | Build Image
           v
       Docker Image
           |
           | Push
           v
       Docker Hub
           |
           | Pull
           v
    Another Developer
           |
           v
     Docker Container

Practical Example

Suppose you want to run an SQL Server container.

Instead of creating a Docker Image from scratch:

  1. Visit Docker Hub.

  2. Search for the SQL Server image.

  3. Download the image using the docker pull command.

  4. Create a container using the downloaded image.

Example Commands:

Download an image:

docker pull hello-world

View downloaded images:

docker images

Run a container:

docker run hello-world

Advantages

  • Easy sharing of Docker Images.

  • Saves development time.

  • Provides ready-made images.

  • Supports public and private repositories.

Key Points

  • Docker Hub is a cloud-based image registry.

  • It stores Docker Images, not running containers.

  • docker pull downloads an image.

  • docker push uploads an image.

  • docker run creates and starts a container from an image.

Interview Questions

  1. What is Docker Hub?

  2. What is the difference between Docker Hub and Docker Engine?

  3. What is the difference between Public and Private repositories?

  4. What is the difference between docker pull and docker push?

 

4. What is the difference between Docker Hub and Docker Engine?

Docker Hub: A cloud-based repository used to store, share, and download Docker Images.

Docker Engine: A software platform installed on a machine to build, run, and manage Docker Containers.

Simple Diagram

              Docker Hub
         (Stores Docker Images)
                  |
                  | Pull Image
                  v
             Docker Engine
          (Runs Docker Containers)
                  |
                  v
           Docker Container
            (Runs Application)

Key Differences

Docker Hub

Docker Engine

Cloud-based image repository.

Software installed on a machine.

Stores and shares Docker Images.

Builds and runs Docker Containers.

Used to upload and download images.

Used to manage containers and images.

Accessed through the internet or registry connection.

Runs locally or on a server.

Example: Docker Hub website.

Example: Docker Engine installed on Windows or Linux.

Practical Example

Suppose you want to run an ASP.NET Core application.

Step 1: Download an image from Docker Hub.

docker pull hello-world

Step 2: Docker Engine uses that image to create and run a container.

docker run hello-world

Key Points

  • Docker Hub = Stores and shares images.

  • Docker Engine = Builds and runs containers.

  • Docker Hub and Docker Engine work together.

  • Docker Engine can also work with other image registries, not just Docker Hub.

Interview Question

Can Docker Engine work without Docker Hub?

Yes. Docker Engine can build images locally and run containers using locally available images. Docker Hub is not mandatory.

 

5. What is the difference between Docker and Virtual Machines?

Docker: Docker runs applications inside lightweight, isolated environments called Containers. Containers share the host operating system's kernel.

Virtual Machine (VM): A Virtual Machine runs a complete operating system inside a virtual environment using a Hypervisor.

How they work

Docker Architecture

       Physical Machine
              |
          Host OS
              |
        Docker Engine
              |
       +------+------+
       |      |      |
      App 1   App 2  App 3
      Container Container Container

Virtual Machine Architecture

       Physical Machine
              |
          Hypervisor
              |
       +------+------+
       |      |      |
      VM 1   VM 2   VM 3
       |      |      |
      OS     OS     OS
       |      |      |
      App    App    App

Key Differences

Docker Containers

Virtual Machines

Share the host OS kernel.

Each VM has its own guest OS.

Lightweight.

Comparatively heavyweight.

Start quickly, usually in seconds or less.

Usually take longer to start.

Require fewer resources.

Require more resources.

Provide process-level isolation.

Provide hardware-level virtualization and stronger isolation boundaries.

Ideal for Microservices.

Ideal for running different operating systems and isolated workloads.

Real-World Example

Suppose you want to host three applications.

Using Virtual Machines:

  • Create 3 Virtual Machines.

  • Install an operating system on each VM.

  • Install and run each application.

Using Docker:

  • Install Docker Engine.

  • Create 3 containers.

  • Run each application inside its container.

Advantages of Docker

  • Less resource consumption.

  • Faster startup.

  • Easy deployment.

  • Suitable for Microservices and CI/CD.

Advantages of Virtual Machines

  • Run different operating systems on the same physical machine.

  • Strong isolation.

  • Suitable for applications requiring a dedicated OS environment.

When should we use them?

Scenario

Recommended

Microservices applications

Docker

Lightweight application deployment

Docker

Running Windows and Linux on the same physical server

Virtual Machines

Full operating system isolation

Virtual Machines

CI/CD pipelines

Docker

Key Points

  • Docker containers share the host OS kernel.

  • VMs have their own guest operating systems.

  • Containers are generally faster and lighter.

  • VMs provide a complete operating system environment.

  • Docker and VMs can also be used together. For example, Docker containers can run inside an Azure Virtual Machine.

 

6. What is the difference between Public and Private Repositories?

In Docker Hub, a Repository is a place where Docker Images are stored and managed.

Public Repository: A repository where anyone can view and download Docker Images without needing permission.

Private Repository: A repository where only authorized users can access and download Docker Images.

Key Differences

Public Repository

Private Repository

Accessible to everyone.

Accessible only to authorized users.

Anyone can download images.

Only users with permission can download images.

No login required for public image downloads.

Authentication is required.

Suitable for open-source projects.

Suitable for company and confidential projects.

Images can be shared publicly.

Images remain restricted.

Practical Example

Suppose you are developing an ASP.NET Core Web API.

Public Repository:

You upload your Docker Image to a public repository.

Docker Hub
    |
    +-- myapi (Public)
           |
           +-- Anyone can download

Another developer can download it:

docker pull username/myapi

Private Repository:

You upload your company's application image to a private repository.

Docker Hub
    |
    +-- company-api (Private)
            |
            +-- Authorized users only

Users must authenticate and have the required permissions to download it.

docker login
docker pull username/company-api

When should we use them?

Scenario

Repository

Open-source projects

Public

Learning and practice

Public

Company applications

Private

Confidential applications

Private

Key Points

  • Public = Anyone can access and download.

  • Private = Only authorized users can access.

  • Both are used to store Docker Images.

  • Private repositories help restrict access to application images.

Interview Question

Can we change a Public Repository to Private?

Yes. Docker Hub allows you to change a repository's visibility from Public to Private through its repository settings, subject to the plan's limits.

 

Docker – Important Interview Questions and Answers

1. What is Docker?

Docker is an open-source platform used to build, package, and run applications inside containers. It helps applications run consistently across different environments.

2. Why do we need Docker?

Docker solves the "works on my machine" problem by packaging an application with its dependencies. It makes application deployment easier and more consistent.

3. What is a Docker Image?

A Docker Image is a read-only template that contains application code, libraries, runtime, and dependencies. It is used to create Docker Containers.

4. What is a Docker Container?

A Docker Container is a running instance of a Docker Image. It provides an isolated environment to execute an application.

5. What is the difference between Docker Image and Container?

An Image is a template used to create containers, whereas a Container is an instance created from that image. One image can create multiple containers.

6. What is Docker Hub?

Docker Hub is a cloud-based repository used to store, share, and download Docker Images. It provides public and private repositories.

7. What is Docker Engine?

Docker Engine is the software responsible for building, running, and managing Docker Images and Containers. It acts as the core runtime of Docker.

8. What is the difference between Docker Hub and Docker Engine?

Docker Hub stores and shares Docker Images, whereas Docker Engine builds and runs containers. Docker Engine can download images from Docker Hub.

9. What is the difference between Docker and Virtual Machines?

Docker containers share the host operating system kernel, whereas Virtual Machines have their own guest operating systems. Containers are generally lightweight and faster to start.

10. Can Docker run inside a Virtual Machine?

Yes. We can install Docker Engine inside a Virtual Machine and run multiple containers within it. This approach is commonly used in cloud environments.

11. What is Dockerfile?

A Dockerfile is a text file containing instructions to build a Docker Image. It defines the application setup, dependencies, environment, and startup command.

12. What is Docker Hub Repository?

A Docker Hub Repository is a place where Docker Images are stored and managed. It can be public or private.

13. What is the difference between Public and Private Repositories?

Public repositories allow anyone to download images, whereas private repositories restrict access to authorized users. Private repositories are useful for company applications.

14. What is the difference between docker pull and docker push?

docker pull downloads a Docker Image from a registry such as Docker Hub. docker push uploads a local image to a registry.

15. Can we create multiple containers from a single Docker Image?

Yes. A single Docker Image can create multiple independent containers. Each container can run the same application separately.

16. Can Docker work without Docker Hub?

Yes. Docker can build images locally and run containers using locally available images. Docker Hub is not mandatory.

17. What happens when we delete a Docker Container?

Deleting a container removes that container and its writable layer, but the original Docker Image remains available. Persistent data stored in external volumes can also remain.

18. Is Docker suitable for Microservices Architecture?

Yes. Docker allows each microservice to run in its own container with independent dependencies. This makes deployment, scaling, and maintenance easier.

 
← Back to Articles