INSIGHTS
DevOps & Automation

What is Docker Technology? How It Works and Why Developers Use It

In this article
  1. Distinguish image, container, engine and registry
  2. Build a small image from a pinned project dependency
  3. Build, run and inspect
  4. Images are not equivalent to virtual machines
  5. Persist data deliberately
  6. Improve production hygiene
  7. Troubleshooting checklist

Docker packages an application and its dependencies into a container image so it can be run consistently across compatible hosts. An image is a read-only filesystem template plus metadata; a container is an instance created from that image. The Docker daemon or another compatible engine manages containers on a host. This tutorial uses one small service to make the build–run–inspect–remove lifecycle visible.

Distinguish image, container, engine and registry

A Dockerfile describes how to assemble an image. docker build creates that image, docker run creates a container, and a registry can distribute image layers. These objects have different lifetimes; removing a container does not necessarily remove its image or uploaded registry copy.

Build a small image from a pinned project dependency

Create an app.py and a Dockerfile in a lab directory. The server listens inside the container on port 8000. The sample chooses a maintained Python image tag for demonstration; production builds should pin an image digest after validating the supplier and update it through a documented patch policy.

from http.server import BaseHTTPRequestHandler, HTTPServer
class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.end_headers()
        self.wfile.write(b"ready\n")
HTTPServer(("0.0.0.0", 8000), Handler).serve_forever()
FROM python:3.13-slim
WORKDIR /app
COPY app.py .
RUN useradd --create-home appuser
USER appuser
EXPOSE 8000
CMD ["python", "app.py"]

Run as a non-root user when the service permits it. A container is not a complete security boundary against an untrusted host or kernel; verify filesystem permissions, privileges and secrets separately.

Build, run and inspect

docker build -t demo-http:local .
docker run --rm --name demo-http -p 127.0.0.1:8000:8000 demo-http:local
# In another terminal:
curl http://127.0.0.1:8000/

Binding to 127.0.0.1 limits host exposure in this local lab. Stop the foreground process with Ctrl+C, or use docker stop demo-http from another terminal. The --rm option removes the container object on normal exit; it does not delete the image.

Images are not equivalent to virtual machines

Ordinary Linux containers use the host kernel, while a traditional VM runs a guest operating system through a hypervisor. Different container runtimes and host platforms may use a VM internally, but that implementation detail does not make a container image a complete guest OS image. Choose VMs when isolation or OS compatibility demands them, and containers when packaging and process-level lifecycle are appropriate.

Persist data deliberately

A container writable layer is generally transient. For durable data, use a volume or an explicitly managed bind mount and a backup strategy. Avoid writing secrets into Dockerfile ENV directives or image layers; they can remain in image history or distributed artifacts. Treat every external image and dependency as a supply-chain input.

Improve production hygiene

Use a minimal trusted base, a .dockerignore file, a multi-stage build for compiled applications, an explicit health check where appropriate, and a CI image-scanning process. Verify that the application handles termination signals and does not require privileged container mode. The official Docker build guidance covers image selection, rebuilds and user permissions.

Troubleshooting checklist

If the build fails, inspect the Dockerfile path and build context. If the container exits immediately, check docker logs and its command. If a service is unreachable, verify the bind address inside the container, host port mapping and whether a firewall blocks it. Do not solve a connectivity issue by adding --privileged.

Filed under DevOps & Automation