Biggest deals of the year. 30-day money-back guarantee. Limited time deals. 24/7 support. Don't miss out

What is Docker? How it works, components, and use cases

Last updated 11 min Read
By Ksenija
What is Docker? How it works, components, and use cases

Find the right learning path for you

  • Free resources
  • Practical tutorials
  • Helpful tools
Explore

Docker is a containerization platform that packages applications and their dependencies into portable, isolated units called containers, enabling them to run consistently across different environments.

To run an application with Docker, you package its code, required libraries, and configuration into a Docker image. Docker then uses the image to create a container and start the application.

Developers use the same image on their computers and compatible servers, keeping the application’s packaged dependencies consistent between development and deployment without repeating the software setup.

Containers also share the host operating system kernel, so they use less memory and storage than virtual machines.

How does Docker work?

Docker follows a process of packaging an application, creating a container to run it, and configuring the storage and connections the application needs.

The workflow consists of seven stages:

  1. Application preparation. You start with application code and a Dockerfile, which tells Docker how to package the application. The Dockerfile specifies the starting software environment, which files to include, and how to run the application.
  2. Image building. Docker follows the Dockerfile instructions to create an image containing the application and its required software.
  1. Image sharing. A container registry, such as Docker Hub, stores images for use on other computers and servers. Docker lets you upload your own images to a registry for distribution or download ready-made images without building them yourself.
  2. Container creation. Docker creates a container from an image and starts the application inside it. Each container runs in isolation from other containers.
  1. Data storage. You attach a Docker volume to the folder where the application stores data, such as database records or uploaded files. Docker keeps the data in the volume even after you remove the container. When you create a replacement container, you attach the same volume so the application has access to its existing data.
  1. Container networking. You connect containers that need to communicate through a shared Docker network. For a website and database running in separate containers, you configure a user-defined network so the website reaches the database by its container name. Docker handles the network connection without requiring a public IP address for each container.
  2. Multi-container management. To manage several related containers together, you define the application’s services, networks, and volumes in a Docker Compose configuration file. Docker Compose uses the file to create and start containers together, then manages them as a single application.

Docker Engine

Docker Engine is the core software that builds Docker images, runs containers, and manages their resources.

It uses a client-server architecture: the Docker command-line interface (CLI), the client, sends your commands through the Docker application programming interface (API) to the Docker daemon (server), which performs the operations on the computer or server running Docker.

Docker Engine consists of three main components:

  • Docker CLI (docker). The command-line interface (CLI) you use to control Docker through a terminal. It accepts commands to perform operations such as building images or starting containers, and then displays the results.
  • Docker daemon (dockerd). The background service that builds images, runs containers, and manages Docker resources, including networks and volumes.
  • Docker API. The application programming interface (API) that connects the CLI and other management tools to the daemon. It allows software to request Docker operations without requiring you to enter commands manually.

The Docker daemon runs independently of your terminal session, so containers running in the background continue operating after you disconnect, provided the server and Docker services remain active.

Docker images and Dockerfiles

A Dockerfile is a text file containing instructions for building a Docker image. It tells Docker which software environment to start with, which application files and dependencies to include, and how to start the application.

Docker follows the instructions to build an image containing the application’s code, libraries, configuration, and any required runtime, such as Python or Node.js.

The Docker image serves as a reusable package for running the application across compatible Docker environments.

Docker builds images in layers, with each layer storing the result of a build step, such as adding application files. When you update an application and rebuild its image, Docker reuses unchanged layers from its cache until it reaches the first changed step, then rebuilds the layers after it, reducing the work required to complete the build.

Images are also immutable, meaning their contents don’t change after Docker builds them. To update an application or its dependencies, you build a new image containing the changes.

The difference between Docker images and containers lies in their roles: an image provides the reusable application package, while a container is the instance Docker creates from that image to run the application.

Docker containers

A Docker container is an instance of a Docker image that runs the application in an isolated environment. When you start a container, Docker launches the application inside it as one or more running processes.

Docker keeps each container’s application files, running processes, and network connections separate from those of other containers. This allows different applications to run on the same server without interfering with one another’s working environments.

Stopping one container, for instance, doesn’t automatically stop applications running in other containers.

Although containers operate separately, they share the operating system kernel of their Docker host. The kernel is the part of an operating system that manages processes, memory, and access to hardware. Docker uses the shared kernel to run containers without requiring a complete operating system inside each one.

Virtual machines (VMs) work differently because each VM runs its own guest operating system. As a result, containers avoid the memory and storage overhead of running separate operating systems, although the resources they consume still depend on the applications running inside them.

You create and manage Docker containers through commands that start, stop, restart, and remove them.

Stopping a container ends its running processes but keeps the container available for restarting. Removing it deletes that instance, while the Docker image remains available for creating another container.

Warning

Docker containers don’t provide the same security isolation as virtual machines. Containers share the host operating system kernel, so attackers who exploit a kernel vulnerability or excessive container permissions may gain access to the host system or other containers.

Docker registries

A Docker registry is a service that stores and distributes Docker images. When you build an image, Docker stores it on your computer or server. Uploading the image to a registry makes it available for other machines to download and run the application.

Registries organize images into repositories, which contain images for a particular application or project. Tags such as 1.0 and 2.0 help distinguish different image versions within a repository.

Docker uses two commands to transfer images between a registry and your computer or server:

  • docker pull downloads an image from a registry so Docker can use it to create containers.
  • docker push uploads an image to a registry repository where other authorized users or systems can retrieve it.

Docker uses Docker Hub as its default image registry, unless you specify a different one. It provides ready-made images for software such as Nginx, PostgreSQL, and Python, allowing you to run applications without building their images yourself.

Docker Hub supports public repositories that anyone can download images from and private repositories accessible only to authorized users.

Organizations that store internal images outside Docker Hub use private registries hosted on their own infrastructure or managed registry services from cloud providers such as Amazon ECR, Azure Container Registry, and Google Artifact Registry.

Docker volumes and networks

Docker volumes preserve application data when you remove or replace containers. Docker networks allow containers to communicate with each other and external services.

Docker volumes store data separately from a container’s filesystem. You connect a volume to a folder inside the container, where the application saves files such as database records or user-uploaded photos. When you replace the container, the new container retrieves the existing data from the same volume.

Docker networks connect containers so the applications running inside them can communicate. For example, a website running in one container exchanges information with a database in another through a shared Docker network.

Docker networking also supports connections to services outside containers, such as payment-processing APIs or databases hosted on other servers, when the network configuration permits it.

To make a website container accessible to visitors, you publish a port, which tells Docker to forward incoming requests from the host computer or server to the website container.

Why use Docker?

Docker helps you set up applications faster, run them consistently across compatible environments, and manage multiple applications on the same server.

Its main benefits include:

  • Environment consistency. Docker packages the software your application needs alongside its code, so you don’t have to install and configure the same dependencies on every machine. Keeping software versions consistent across development, testing, and production reduces errors caused by mismatched environments.
  • Portability. Docker lets you move application images between compatible environments, such as your computer, a virtual private server (VPS), or a cloud server. You can deploy the same packaged application on each machine without reinstalling its software dependencies.
  • Faster setup. Docker uses existing images to recreate application environments without requiring you to install and configure every dependency manually.
  • Resource efficiency. Containers share the host operating system kernel, avoiding the memory and storage overhead of running a separate guest operating system for each application.
  • Isolation. Docker separates application processes and dependencies into individual containers, reducing conflicts between applications running on the same host.
  • Reproducibility. Dockerfiles provide a shared set of instructions for building an application image, so developers follow the same process when recreating it. Specifying software versions helps keep builds consistent, making it easier to reproduce errors, test fixes, and verify that changes work as expected.
  • Distribution. Docker registries let you share application images with other developers and servers. Once your team tests an image, you can distribute the same tested version without rebuilding the application on every machine, reducing the risk of differences between builds.

Important

Docker improves application portability but doesn’t guarantee identical behavior across environments. Before deploying, verify that the Docker image supports the target operating system and CPU architecture. When moving an application to an environment with different network ports, host file paths, or external service addresses, update its configuration to match the new environment.

What is Docker used for?

Docker is used for local application development and testing, automating software builds and tests, managing applications with multiple services, and deploying or self-hosting applications on servers.

Hostinger’s internal VPS deployment data shows which applications people self-host using Docker Compose.

As of November 27, 2026, the AI agents OpenClaw and Hermes Agent were the most common first Docker Compose deployments, running on 44,721 and 30,314 VPSs, respectively. The workflow automation platform n8n ranked third with 18,663 VPSs.

The ranking also includes software for managing web traffic, databases, and websites, such as Traefik, PostgreSQL, and WordPress.

Local development and testing

During local development, Docker runs the supporting services your application needs, such as databases, caches, and message brokers, on your computer. You develop the application, test changes against those services, and check how different software versions affect its behavior.

For testing, Docker provides temporary environments where you test new features, reproduce errors, and verify fixes before deployment. After completing a test, you remove the containers and start fresh for the next one.

Docker Desktop provides a local Docker development environment for Windows, macOS, and Linux. It includes Docker Engine, the Docker CLI, Docker Compose, and a graphical interface for managing images and containers. On Windows and macOS, Docker Desktop runs Docker Engine inside a lightweight Linux virtual machine because Linux containers need a Linux kernel.

The interface shows running containers, their status, and logs, giving you a convenient way to monitor applications during development.

CI/CD

Docker supports continuous integration and continuous delivery/deployment (CI/CD) by providing consistent environments for automated software builds, testing, and releases.

When you submit a code change, a CI/CD tool such as GitHub Actions or Jenkins starts a pipeline that builds the application and runs automated tests.

The pipeline uses Docker to start temporary containers for tests that require isolated environments or supporting services, such as databases.

For pipelines that deploy applications from an image registry, the release stage publishes the application’s Docker image after the required tests pass. The deployment system then retrieves the image and starts the updated application.

Microservices and multi-service applications

Docker runs different parts of an application in separate containers, each with its own code and software dependencies.

In a microservices architecture, you can use Docker to run services such as product inventory, order processing, and payments independently. When you update one service, you build its new image and replace its container without rebuilding the others.

Docker networking connects containers running different application services. When containers share a user-defined Docker network, Docker assigns them IP addresses and makes them reachable by name through its built-in Domain Name System (DNS) service.

For example, an order-processing application can send a request to a container named inventory to check stock availability. Docker handles name resolution and network connectivity, while the applications handle the requests and responses.

Docker Compose manages the setup through a single YAML configuration file. You define which services to run, which images to use, how the containers connect, and where they store data.

Running docker compose up creates and starts the configured services together. You can use Compose for microservices or simpler applications, such as a website with a database.

Deploying and self-hosting applications

Docker allows you to deploy websites, APIs, and background services on VPSs, cloud servers, developer machines, and other compatible environments.

For self-hosting, you use Docker to run packaged software on servers you manage, including WordPress websites, automation platforms, and AI agents.

Moving a self-hosted application to another server involves recreating its deployment using the same Docker images and configuration, then restoring persistent data such as database records and uploaded files.

Docker Compose, Kubernetes, and Swarm mode

Docker Compose defines and runs related services on a single Docker host. Kubernetes and Swarm mode coordinate workloads across multiple hosts, scheduling containers across servers and maintaining the required number of running instances. These tools solve different problems, so they aren’t interchangeable alternatives.

Docker Compose

Docker Compose defines and manages multi-container applications through a single YAML configuration file.

In the file, you specify the application’s services, including their Docker images or build instructions, along with the networks connecting the containers and the volumes storing their data. Docker recommends naming the file compose.yaml.

You use Docker Compose during local development to run related services together, such as a website, application server, and database. It also supports multi-container deployments on a single server, including a VPS.

The docker compose up -d command tells Compose to read the configuration and instruct Docker Engine to create and start the application’s containers and other required resources in the background.

On a Linux VPS, you manage the application through the Linux command line, using docker compose ps to check service status and docker compose down to stop and remove the containers and project networks. Named volumes and their data remain unless you add the -v flag.

Kubernetes

Kubernetes is a separate, open-source platform for managing containerized applications across a cluster (a group of servers working together).

It coordinates applications that run on multiple servers, including where their containers run, how they scale, and what happens when part of the deployment fails.

Kubernetes organizes containers into units called Pods. Each Pod contains one or more containers that run together on the same server.

Kubernetes container orchestration assigns Pods to servers with available resources and creates replacements when Pods fail.

With automatic scaling configured, Kubernetes also adjusts the number of Pods according to the application’s workload.

When you use Docker with Kubernetes, you build the application’s container image with Docker and publish it to a registry. Kubernetes then decides which servers in the cluster should run the application.

Each server uses a container runtime, software that starts and runs containers from images. Kubernetes supports runtimes such as containerd and CRI-O, so it doesn’t require Docker Engine on its servers.

Swarm mode

Swarm mode is Docker Engine’s built-in feature for managing application services across multiple Docker hosts. It groups the hosts into a cluster called a swarm, where each participating computer or server becomes a node.

Nodes have two roles. Manager nodes decide where to run the application’s containers and monitor their status across the cluster. Worker nodes run the containers assigned by the managers.

When you deploy a service, you specify its Docker image and the number of container instances, called replicas, that Docker should maintain.

For a web service configured with three replicas, Swarm schedules three containers across available nodes and moves them to other nodes when a server becomes unavailable.

Applications that run several containers on one server don’t need Swarm mode. Start with Docker Compose, and move to Swarm mode only when your services must run across multiple Docker hosts.

To use Docker Engine’s built-in orchestration, you create a Docker Swarm that connects the hosts and coordinates where the services run.

Start with one container, then build from there

Start with a ready-made Docker image, such as Nginx from Docker Hub, and follow these steps:

  1. Run a web server in a container using the Nginx image.
  2. Open the Nginx welcome page in your browser to verify that the container is running.
  3. Stop and remove the container.
  4. Start a new container from the same image to see how images and containers relate.
  5. Once you’re familiar with this process, create a Dockerfile and build an image for your own application.

As your application takes shape, add the components it requires. Use volumes to preserve data, Docker networking to connect services, and Docker Compose to manage multiple containers together.

Save Kubernetes and Swarm mode for deployments that require orchestration across multiple servers. Neither is necessary for getting started with Docker.

For projects you want to host on a server, Hostinger’s Docker VPS hosting offers an Ubuntu 24.04 template with Docker Engine and Docker Compose preinstalled.

You retain access to Docker commands via Secure Shell (SSH), while the Docker Manager in the Hostinger dashboard provides a visual interface for deploying and managing applications.

Docker Manager supports several deployment methods: entering a Compose configuration in its editor, importing one from a GitHub or GitLab repository, or selecting a preconfigured application from Hostinger’s Docker catalog.

Once your application is running, you can monitor its resource usage, review container logs, and restart or update projects directly through the Hostinger dashboard.

All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.

Author
The author

Ksenija Drobac Ristovic

Ksenija is passionate about exploring how AI is changing the digital world. Her work focuses on AI, agentic systems, AI search, and the technologies shaping how people interact with the web. She enjoys digging into new developments, understanding how they work, and making them easier to navigate. When she’s not writing or editing, you’ll find her on the local basketball court or at home enjoying a crime story. Follow her on LinkedIn.

You're making progress!

An illustration for the Pillar 6: The Engineer featuring UI elements like image, microfon and AI icons, a menu icon, and a backdrop with a lamp and a vase, with violet background
Pillar 6: Take control of your server

Keep deploying your project

Continue with the next article in this path and get your project live.

  • Free resources
  • Interactive quizzes
  • Helpful tools
Continue learning

Trusted by 4+ million website owners worldwide

See our 74,701 reviews on Trustpilot

Not sure which plan to choose?

Our smart AI agent, is here to help you find the best package for your project.

See Pricing