What is Docker?

Author: Published

In brief: Docker is a platform for building and running applications in containers: isolated environments with the necessary libraries and tools. It helps reproduce similar conditions on a developer’s computer, during testing and on a server. It does not replace hosting and is not a full virtual machine.

How Docker works and what a container is

An application needs not only code but also a runtime environment: for example, a specific version of Python, libraries and system tools. When these elements differ between computers, a program may work for one person but produce errors for another. Docker helps define and prepare these dependencies in a repeatable way.

A container is a running process or group of processes isolated from the rest of the system. The application sees its own file system and has a separate working environment. Resource limits can also be set, such as limits on memory and CPU usage.

Containers share the operating system kernel, the part responsible for handling processes and hardware, among other things. In a typical Linux environment, they use the host’s kernel. Running Linux containers through Docker Desktop on macOS and Windows requires a Linux layer, provided by a virtual machine or a mechanism such as WSL 2.

Docker reduces differences between environments, but it does not eliminate them entirely. Processor architecture, configuration, network access and the external services the application connects to still matter.

Images, Dockerfiles and volumes — basic concepts

To understand a typical project, you need to distinguish between a few elements:

The difference between an image and a container is similar to the difference between a document template and an open document created from it. The image remains the starting point, while each container has its own runtime state and writable file layer.

Database data should not be stored solely in the container’s writable layer. Simply stopping the container does not delete the data, but deleting the container means losing that layer. A volume allows data to be retained when a container is replaced, but it is not a substitute for a backup and can also be deleted.

Docker versus a virtual machine

A virtual machine runs a separate operating system with its own kernel. A container does not need a full guest operating system because it uses a shared kernel. This is why containers usually start faster and have less resource overhead than full virtual machines.

This does not mean Docker is always the better choice. A virtual machine is useful when you need a separate operating system, a different kernel or a stronger isolation boundary. Containers are well suited to packaging and running application services, but their isolation should not be treated as equivalent to that of a separate machine.

These solutions often work together: you can run Docker on a rented virtual server and run several containers within it. Hosting then provides the resources, while Docker organises how the applications are run.

Example: a website with an application and a database

Suppose you are building a website with a customer portal. The project requires a Python application and a PostgreSQL database. Without containers, each person on the team has to install compatible versions of both components themselves and configure them to work together.

With Docker Compose, you can define two services: the application and the database. Each runs in a separate container, and they communicate over a shared network. PostgreSQL data is stored in a volume, and a selected application port is exposed on the user’s computer.

A typical workflow looks like this:

  1. The team writes the application build instructions in a Dockerfile.
  2. In the Compose file, it defines the services, network, volume and required settings.
  3. A developer downloads the project, fills in the local configuration and runs docker compose up --build.
  4. Docker builds the application image, downloads the required database image and starts the containers.

The command will work only in a properly prepared project and with Docker running. When deploying to a server, you still need to take care of passwords, a TLS certificate, backups, updates and monitoring. A local configuration does not automatically become a secure production configuration.

When to use Docker and how to get started

Docker is particularly helpful when a project has several services, a team needs a consistent environment or an application is frequently deployed to a server. It also makes it easier to test different versions of dependencies without installing them directly on the main system.

For a simple static website or a single script, the extra files and container management may be unnecessary work. Standard shared hosting may not allow Docker to run either — you need to confirm this with the provider.

To get started, choose a small project and run one service. Use a trusted image, check its documentation and expose only the ports you need. Consult Docker’s official documentation to confirm the installation procedure for your operating system and the current Docker Desktop licence terms, especially before using it for business purposes.

See also: What is a CDN?

Read also

Learn how PHP-FPM handles PHP requests, how it differs from a web server, and how to tune processes for traffic and hosting resources.
Learn how BIND, open-source DNS server software, handles domains, how its two roles differ and when running it yourself makes sense.
Learn what Poland’s REGON register and identification number mean, how they differ from NIP and KRS, and how to check a business’s details.