<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/docker-in-2026-the-5-mistakes-still-killing-your-containers-in-production-smjgbcw2q" -->

---
title: Docker in 2026: The 5 Mistakes Still Killing Your...
description: Five persistent Docker mistakes still found in production environments in 2026: running containers as root (fix: add a non-root user in Dockerfile), using...
canonical: https://daily.dev/posts/docker-in-2026-the-5-mistakes-still-killing-your-containers-in-production-smjgbcw2q
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Docker in 2026: The 5 Mistakes Still Killing Your Containers in Production | daily.dev
og:description: Five persistent Docker mistakes still found in production environments in 2026: running containers as root (fix: add a non-root user in Dockerfile), using...
og:url: https://daily.dev/posts/docker-in-2026-the-5-mistakes-still-killing-your-containers-in-production-smjgbcw2q
og:image: https://api.daily.dev/og/posts/smjGbcw2q.png
og:image:alt: Docker in 2026: The 5 Mistakes Still Killing Your Containers in Production
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker in 2026: The 5 Mistakes Still Killing Your Containers in Production

**[sirajju](https://daily.dev/sources/giqfobcn9hyxcvrvo3s95)** · [@sirajju](https://daily.dev/sirajju) · 3 min read · 1 upvotes · 1 comments

## Summary

Five persistent Docker mistakes still found in production environments in 2026: running containers as root (fix: add a non-root user in Dockerfile), using 'latest' image tags (fix: pin exact versions), bloated single-stage images with build dependencies (fix: multi-stage builds), missing health checks (fix: add HEALTHCHECK instruction), and ignoring .dockerignore (fix: exclude node_modules, .git, .env, etc.). A bonus warning advises against using docker-compose in production, recommending proper orchestration instead. Each mistake includes a concrete Dockerfile snippet or config example.

## Content

Docker has been mainstream for over a decade now. We should have figured it out by now. And yet, I keep seeing the same container mistakes in production — at startups, at enterprises, at companies that should absolutely know better.

Here are the 5 most common Docker mistakes I still encounter in 2026, and what to do instead.

## Mistake 1: Running as root inside containers

This is still the #1 security issue I see in container audits. Your Dockerfile doesn't specify a user, so everything runs as root. Inside the container, this means a vulnerability in your app gives an attacker root-level access to the container filesystem, and potentially a path to escape to the host.

**The fix:**

```dockerfile
FROM node:22-slim
RUN groupadd -r appuser && useradd -r -g appuser appuser
WORKDIR /app
COPY --chown=appuser:appuser . .
RUN npm ci --production
USER appuser
CMD ["node", "server.js"]
```

Always create a non-root user. Always switch to it before CMD. This takes 2 lines and prevents an entire class of attacks.

## Mistake 2: Using latest tags in production

`FROM node:latest` is a time bomb. Your build works today. In 3 months, `latest` points to a new major version. Your build breaks — or worse, it succeeds but your app behaves differently.

**The fix:** Pin exact versions. `FROM node:22.17.0-slim`. Lock it in your CI. Update deliberately, not accidentally.

## Mistake 3: Bloated images with build dependencies

Your production image doesn't need gcc, make, python, or your test framework. But single-stage Dockerfiles ship all of this to production, creating 2GB+ images that take forever to pull and contain unnecessary attack surface.

**The fix — multi-stage builds:**

```dockerfile
# Build stage
FROM node:22 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Production stage
FROM node:22-slim
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
USER appuser
CMD ["node", "dist/server.js"]
```

Your production image should contain only what's needed to run. Nothing more.

## Mistake 4: No health checks

Without a HEALTHCHECK instruction, Docker and your orchestrator have no way to know if your app is actually working. The container could be running but the process inside is deadlocked, out of memory, or stuck in an infinite loop.

**The fix:**

```dockerfile
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
  CMD curl -f http://localhost:3000/health || exit 1
```

This gives your orchestrator real information to make restart decisions, not just "is the PID alive."

## Mistake 5: Ignoring .dockerignore

No `.dockerignore` means Docker copies your entire directory into the build context — including `node_modules`, `.git`, `.env` files with secrets, test fixtures, and everything else. This slows builds, bloats images, and can leak sensitive data.

**The fix:**

```
# .dockerignore
node_modules
.git
.env
*.log
test/
coverage/
.DS_Store
```

Think of `.dockerignore` as your `.gitignore` for containers. If you don't need it at runtime, exclude it.

## Bonus: Stop using docker-compose in production

Docker Compose is for local development. If you're running `docker-compose up -d` on a production server and calling it deployment, you're one crashed server away from losing everything. Use proper orchestration — even a simple systemd unit file is better than hoping someone remembers to restart compose after a reboot.

Containers aren't complicated. But the defaults are wrong for production, and the documentation buries the important stuff under tutorials about building a todo app. Get these 5 things right and you'll avoid 90% of container incidents.

What Docker mistake cost your team the most time? Share your war stories below.

## Community discussion

Top comments from developers on daily.dev.

**@sirajju** · 0 upvotes

> The "running as root" one still shocks me in 2026. I recently audited a fintech startup with 50+ containers — every single one was running as root. Two lines of Dockerfile config could have saved them from a critical security finding.

## Similar posts on daily.dev

- [Docker Security: The Mistakes Everyone Makes](https://daily.dev/posts/docker-security-the-mistakes-everyone-makes-hksmiab4l) · Medium · 1 upvotes · 2 comments
- [Should I Run Plain Docker Compose in Production in 2026?](https://daily.dev/posts/should-i-run-plain-docker-compose-in-production-in-2026--um5g4e1wi) · Hacker News · 2 upvotes · 0 comments
- [Best of 2025: Docker Security in 2025: Best Practices to Protect Your Containers From Cyberthreats](https://daily.dev/posts/best-of-2025-docker-security-in-2025-best-practices-to-protect-your-containers-from-cyberthreats-z5h9prrdx) · Cloud Native Now · 0 upvotes · 0 comments

---

Tags: [#devops](https://daily.dev/tags/devops), [#docker](https://daily.dev/tags/docker), [#containers](https://daily.dev/tags/containers)

[View this post on daily.dev](https://daily.dev/posts/docker-in-2026-the-5-mistakes-still-killing-your-containers-in-production-smjgbcw2q)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/docker-in-2026-the-5-mistakes-still-killing-your-containers-in-production-smjgbcw2q","headline":"Docker in 2026: The 5 Mistakes Still Killing Your Containers in Production","text":"Five persistent Docker mistakes still found in production environments in 2026: running containers as root (fix: add a non-root user in Dockerfile), using 'latest' image tags (fix: pin exact versions), bloated single-stage images with build dependencies (fix: multi-stage builds), missing health checks (fix: add HEALTHCHECK instruction), and ignoring .dockerignore (fix: exclude node_modules, .git, .env, etc.). A bonus warning advises against using docker-compose in production, recommending proper orchestration instead. Each mistake includes a concrete Dockerfile snippet or config example.","url":"https://daily.dev/posts/docker-in-2026-the-5-mistakes-still-killing-your-containers-in-production-smjgbcw2q","datePublished":"2026-03-06T06:23:08.283Z","dateModified":"2026-03-06T06:23:26.618Z","author":{"@type":"Person","name":"sirajju","url":"https://daily.dev/sirajju","image":"https://media.daily.dev/image/upload/s--IbwvoTYq--/f_auto/v1772778404/avatars/avatar_giQfoBCN9hYxcvRVo3s95?_a=BAMAMiiu0","description":"Empty","worksFor":{"@type":"Organization","name":"Acodez","logo":"https://res.cloudinary.com/daily-now/image/upload/s--9-AnYpsB--/f_auto/v1725541842/companies/acodez"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":260}},"interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"comment":[{"@type":"Comment","text":"The “running as root” one still shocks me in 2026. I recently audited a fintech startup with 50+ containers — every single one was running as root. Two lines of Dockerfile config could have saved them from a critical security finding.","datePublished":"2026-03-06T06:23:11.313Z","url":"https://daily.dev/posts/smjGbcw2q#c-gQCistDsa","author":{"@type":"Person","name":"sirajju","url":"https://daily.dev/sirajju","image":"https://media.daily.dev/image/upload/s--IbwvoTYq--/f_auto/v1772778404/avatars/avatar_giQfoBCN9hYxcvRVo3s95?_a=BAMAMiiu0"}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/giqfobcn9hyxcvrvo3s95","name":"sirajju"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"sirajju","item":"https://daily.dev/sources/giqfobcn9hyxcvrvo3s95"},{"@type":"ListItem","position":3,"name":"Docker in 2026: The 5 Mistakes Still Killing Your Containers in Production"}]}
```

