Docker Devops Guide - skillgohub.com

Published: 2026-08-01 | Category: Guides | ⏱️ 15 min read
docker devops guideguidehow-to
Docker Devops SkillGoHubcom — skillgohub.com

Docker revolutionized software development by making environments portable, reproducible, and scalable. In 2026, Docker is an essential tool in every developer's toolkit, used by 89% of organizations according to the Cloud Native Computing Foundation's annual survey. This guide covers everything from containers basics to production deployment.

Every DevOps engineer has been there: your Docker image builds fine on a laptop, then fails in production with a cryptic exec format error or a missing library that only surfaces three days later. Docker adoption is not really about learning docker run — it is about engineering the container workflow so that build, ship, and run stay reproducible under real load. By 2026, roughly 40% of organizations running containers report that half their deployments are still manual, and the gap between teams that containerize properly and those that simply "paste a Dockerfile" shows up as downtime, image bloat, and costly late-night rollbacks.

This guide is structured as a decision path, not a feature tour. You will go from picking a base image all the way to running containers in a real CI/CD pipeline, with concrete commands, real registry pricing, and the pitfalls that commonly break teams in production.

Start With the Base Image Decision

The base image is the highest-leverage decision in Docker, and most beginners get it wrong by defaulting to the full-size image. A typical ubuntu:latest base adds 70–80 MB of padding before you install anything, and if that package set includes a compiler toolchain, your final image can balloon past 1 GB. Every megabyte matters when you are pulling images across a CI pipeline and storing them in a registry that charges per gigabyte.

Docker Devops Guide - featured image

A practical rule of thumb is to match the base to your runtime, not your build host:

A Multi-Stage Build That Actually Shrinks Images

Multi-stage builds are the single most effective technique for cutting image size, yet many Dockerfiles still copy the toolchain into the final image. The pattern is simple: use one stage to compile or install dependencies, then copy only the artifacts you need into a fresh, lean final stage.

Docker Devops Guide comparison and review

For a Node.js application the pattern looks like this:

  1. Stage 1 (builder) installs dependencies with npm ci --production=false and builds the app.
  2. Stage 2 (prod-deps) installs only production dependencies.
  3. Stage 3 (runtime) copies over the compiled output plus node_modules from stage 2, then runs as a non-root user.

The result is often a drop from 900 MB to under 150 MB with no functional change. The image also becomes safer because the build-stage credentials and source files never reach the registry. If you are new to the broader tooling landscape, our DevOps tools guide walks through how container registries, orchestration, and CI systems fit together.

Layer Caching: The Build Speed Multiplier

Layer caching is where most teams lose minutes per build without realizing it. Docker builds each instruction as a layer and caches layers that are unchanged. The trick is to order instructions so that frequently changing files come last. Copy your package.json or requirements.txt first, run the dependency install, and only then copy the rest of the source. That way, a single code change does not invalidate the expensive dependency layer.

Docker Devops Guide step by step guide

A common mistake is copying the entire source with COPY . . before running npm install, which invalidates the cache on every single file edit. Add a .dockerignore file immediately to exclude node_modules, .git, local logs, and build artifacts. Teams that skip this discover the hard way that a 10 KB code edit triggers a full dependency reinstall that takes ten minutes instead of ten seconds.

Choosing a Container Registry

Your registry determines your pull speed, your storage bill, and often your security posture. The options differ substantially in free tiers and pricing per gigabyte, so it pays to compare before committing. The table below compares the registries you are most likely to encounter in 2026.

Docker Devops Guide cost and pricing analysis
Platform / ToolKey FeaturesPricing
Docker HubLargest ecosystem, official images, simple CLI integrationFree for 1 private repo plus unlimited public images; $9/month Pro for more private repos
GitHub Container Registry (GHCR)Pulls tied to GitHub packages, fine-grained access, native Actions supportFree for public packages; private packages use GitHub storage/egress quotas
AWS Elastic Container Registry (ECR)IAM integration, image scanning, lifecycle policiesFree tier 500 MB/month storage; ~$0.10/GB/month after, plus data transfer costs
Google Artifact RegistryMulti-format (Docker, Maven, npm), regional replicationFree 500 MB/month; ~$0.10/GB/month storage plus network costs
Azure Container RegistryManaged ACR, geo-replication, AKS tight couplingBasic tier starts ~$5/month; storage and bandwidth billed separately
HarborSelf-hosted, vulnerability scanning, role-based access controlOpen source (free), you host and operate it

For a solo project or early-stage startup, starting with GitHub Container Registry or Docker Hub's free tier is the fastest path. As you scale, weigh ECR or Artifact Registry if you already run on that cloud — the closer the registry is to your compute region, the lower your egress and pull latency.

Orchestration: Know When Docker Compose Is Not Enough

Docker Compose handles local multi-container setups well, but it is not a production orchestrator. Compose has no built-in auto-scaling, no rolling-deployment semantics, and no self-healing for crashed nodes. If you are running a handful of containers on a single VPS, Compose with a restart policy may be enough. The moment you have multiple workers, need zero-downtime deploys, or want to spread load across machines, you need a cluster.

Docker Devops Guide tools and features overview

Kubernetes remains the default choice, but it brings real operational weight — a control plane to maintain, RBAC to configure, and a learning curve that trips up many teams. Lighter options such as Docker Swarm still exist but have seen far slower development; most teams migrating off Swarm in recent years moved to Kubernetes or a managed distribution. For a decision-oriented view of orchestration and the surrounding ecosystem, our DevOps fundamentals for 2026 article covers how these tools evolved and which ones teams are actually adopting.

Getting the Dockerfile Right: Health Checks and Non-Root Users

Two configuration details separate production-ready Dockerfiles from demos. First, define a HEALTHCHECK so orchestrators and Load Balancers know the container is actually serving requests, not just running a process. Second, run as a non-root user with the USER instruction — the default root user inside a container is one of the most common security findings in image scans. The API security basics material emphasizes the same principle from the application side: least privilege applies to containers too.

A minimal pattern is:

Wiring Containers Into CI/CD

Once your image builds cleanly, the pipeline around it matters more than the Dockerfile itself. A standard flow in GitHub Actions, GitLab CI, or Jenkins looks like this:

  1. Lint and validate the Dockerfile on every push.
  2. Build the image and run tests inside the container (docker compose up for integration tests).
  3. Scan the image for vulnerabilities using a tool such as Trivy, which is free and open source, or a paid scanner.
  4. Push the image to the registry only after scans pass.
  5. Deploy by referencing the immutable image digest rather than a mutable latest tag.

The immutable-digest rule is the one that prevents the most "works locally, breaks in prod" incidents. Tagging with latest makes rollbacks unreliable because you lose track of what exactly ran. Use the commit SHA or a build ID as the tag, and keep latest only as a convenience pointer.

Debugging Containers That Fail in Production

When a container misbehaves, resist the urge to docker exec and patch things live — changes inside a running container are ephemeral and vanish on the next deploy. Instead, reproduce the failure locally with the same image tag and environment variables, and capture logs with docker logs. If the image is large or a dependency only breaks on a specific architecture, verify the platform flag with docker build --platform so the base image matches your target (this is the classic cause of the exec format error on ARM vs x86).

For disk-full failures, use docker system prune to clear dangling images and unused build cache only after confirming no running container needs them. If you are just starting with the fundamentals and want a structured path, our Learn Docker 2026 guide walks through the full beginner journey step by step.

For more, check out: .

For more, check out: .

Frequently Asked Questions

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

An image is a read-only, immutable template — the Dockerfile baked into a filesystem snapshot. A container is a running instance of that image, with its own writable layer on top. You can run many containers from one image, and each container's changes are discarded when it stops.

How do I reduce the size of my Docker image?

Use a slim or distroless base, apply multi-stage builds so the toolchain stays out of the final image, install dependencies before copying source to preserve layer cache, and add a .dockerignore. These four changes routinely cut images from hundreds of megabytes to well under 100 MB.

Should I use Docker Compose or Kubernetes in production?

Use Docker Compose for small, single-host workloads where a restart policy and manual scaling are enough. Move to Kubernetes when you need auto-scaling, zero-downtime rollouts, multi-node scheduling, or self-healing across machines — but budget for the added control-plane complexity and operational overhead.

Where can I go next after learning the Docker basics?

Apply the fundamentals to a real CI/CD pipeline and a production-style deployment. Our DevOps tools guide connects Docker to orchestration, registries, and CI systems, and the DevOps fundamentals for 2026 article broadens this into the wider delivery landscape so the container work slots into a complete workflow.

Why does my Docker image fail with an "exec format error"?

This usually means the base image architecture does not match your host's CPU. If you build on an ARM Mac and deploy to x86 servers, rebuild with the correct --platform flag and push architecture-specific images, or use a registry that stores and serves multiple platform manifests.

Is it safe to run containers as the root user?

No. Root inside a container still maps to a powerful user at the kernel level, so a container escape or misconfigured volume can escalate privileges. Create a non-root user in the Dockerfile with USER, and scan your image with a tool like Trivy to catch such issues before deployment.