Docker

Docker is a platform for building, packaging, and running applications in containers, which bundle code with its dependencies so it runs the same everywhere.

Table of Contents

Table of Contents

Further Reading

No items found.
No items found.
No items found.
No items found.
No items found.
No items found.

What Does Docker Mean?

Docker is a platform that simplifies building, packaging, and running applications inside containers. Containers bundle code with its dependencies for a consistent environment.

Teams build an image once and run it anywhere. That reduces environment headaches and improves portability across development, testing, and production.

How Docker Works

  1. Write a Dockerfile: list the base image, dependencies, and commands.
  2. Build an image: Docker creates a layered, read-only image.
  3. Push to a registry: store and version the image.
  4. Run containers: start isolated instances from the image anywhere.

Here is a simple Dockerfile for a Playwright test suite:

FROM node:20-alpine
WORKDIR /tests
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["npx", "playwright", "test"]

Docker vs. Virtual Machines

Aspect Docker Containers Virtual Machines
Operating system Share the host kernel Each runs a full guest OS
Startup Seconds Minutes
Footprint Megabytes Gigabytes
Portability Same image runs anywhere Heavier images, hypervisor-dependent

Why Docker Matters

  • Consistency: apps behave the same on any infrastructure
  • Efficiency: shared kernels make containers lighter than VMs
  • Scalability: containers start and stop quickly
  • Ecosystem: registries, orchestration, and developer tools support it
  • Reproducible tests: every environment uses the same image

Docker and Kubernetes

Docker builds and packages images. Kubernetes orchestrates containers across clusters, handling scheduling, scaling, and recovery.

Modern Kubernetes runs containers with runtimes like containerd or CRI-O. Images built with Docker follow OCI standards, so they run on those runtimes unchanged.

Real-World Example

A B2B SaaS team packages a microservice into a Docker image and pushes it to a registry. QA uses that image for automated tests, staging for integration checks, and production for deployment.

The team also packages its Playwright suite as an image. Testkube runs that image in the staging cluster, so tests and app share the same environment.

How Docker Relates to Testkube

  • Image-based tests: any test tool packaged in an image can run in a Testkube workflow
  • Isolated pods: each run starts from a clean container
  • Consistent environments: the same image runs locally, in CI, and in clusters
  • Custom tooling: bring your own images for specialized tests

Best Practices for Docker Images

  • Use small base images: faster pulls and fewer vulnerabilities
  • Pin versions: avoid surprise changes from latest tags
  • Use multi-stage builds: keep build tools out of runtime images
  • Scan images: catch vulnerabilities early
  • Run as non-root: limit damage from compromises

Frequently Asked Questions (FAQs)

What is the difference between Docker and a container?

A container is an isolated unit with an app and its dependencies. Docker is a platform for building, packaging, and running containers.

What is the difference between a Docker image and a container?

An image is a read-only template with code and dependencies. A container is a running instance created from that image.

How is Docker different from a virtual machine?

Containers share the host kernel, so they are lighter and start faster than VMs, which each run a full operating system.

How does Docker relate to Kubernetes?

Docker builds and packages images. Kubernetes orchestrates the resulting containers across clusters.

Why is Docker useful for testing?

The same image runs in development, QA, staging, and production, so tests are consistent and easy to reproduce.

How does Testkube use containers for testing?

Testkube runs test tools from container images as pods inside your Kubernetes clusters.

Related Terms and Concepts

No items found.