CLAUDE LABJP
MCP — The July 28 MCP spec release candidate drops the Mcp-Session-Id header and goes stateless, so remote MCP servers no longer need sticky sessionsAPPS — The same release adds MCP Apps for server-rendered UI and a Tasks extension for long-running workMEMORY — The Python 0.116.0, TypeScript 0.110.0, and Go 1.56.0 SDKs now send agent-memory-2026-07-22 on every memory store callSPILL — Output from agent_toolset and MCP tools past 100K characters now spills to a file in the sandbox, with the model receiving a truncated preview it can expandBG — MCP tool calls running past two minutes move to the background automatically, keeping the session usable; tune it with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSRESUME — Typing /resume in the agent view opens a picker of past sessions and brings your pick back as a background sessionMCP — The July 28 MCP spec release candidate drops the Mcp-Session-Id header and goes stateless, so remote MCP servers no longer need sticky sessionsAPPS — The same release adds MCP Apps for server-rendered UI and a Tasks extension for long-running workMEMORY — The Python 0.116.0, TypeScript 0.110.0, and Go 1.56.0 SDKs now send agent-memory-2026-07-22 on every memory store callSPILL — Output from agent_toolset and MCP tools past 100K characters now spills to a file in the sandbox, with the model receiving a truncated preview it can expandBG — MCP tool calls running past two minutes move to the background automatically, keeping the session usable; tune it with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSRESUME — Typing /resume in the agent view opens a picker of past sessions and brings your pick back as a background session
Articles/Claude Code
Claude Code/2026-04-09Advanced

Claude Code × Docker — DevContainers, Multi-Stage Builds, and Production Deployment

A practical guide to production-grade development workflows combining Claude Code and Docker. From DevContainer setup and multi-stage build optimization to GitHub Actions CI/CD and Kubernetes deployment — with practical code examples throughout.

Claude Code202Docker5DevContainerCI/CD18KubernetesProduction23

Premium Article

Container technology is an essential part of modern software development. Yet many developers still struggle with questions like "How should I structure my Dockerfile?", "DevContainer configuration is too complex", or "I keep running into issues when moving to production."

Claude Code dramatically solves these Docker-related challenges. You can ask it to optimize your Dockerfile in natural language, paste error messages directly and let it diagnose the cause, or automate the generation of complex Kubernetes YAML.

Below is a production-grade development and deployment workflow built from Claude Code and Docker, step by step, with real code. DevContainer setup, multi-stage builds, Docker Compose for local development, GitHub Actions CI/CD, and production deployment to Kubernetes or Fly.io.

This guide is designed for intermediate-to-advanced engineers who have basic Docker knowledge but haven't yet taken the leap into production operations. With Claude Code, you'll compress work that used to take days into hours.


DevContainer × Claude Code — Build a Reproducible Dev Environment in 5 Minutes

What Is DevContainer?

DevContainer is a mechanism used with VS Code or GitHub Codespaces that lets you define your development environment as code. Every team member works in an identical environment, eliminating the classic "it works on my machine" problem.

With Claude Code, you can generate and optimize .devcontainer/devcontainer.json files using natural language.

Generating a DevContainer with Claude Code

Run the following from your project root:

# Example Claude Code request
claude "Create a devcontainer.json for a project using Node.js 22 + TypeScript + PostgreSQL 16.
Also run npm install in the postCreateCommand."

Example generated .devcontainer/devcontainer.json:

{
  "name": "Node.js + TypeScript + PostgreSQL",
  "dockerComposeFile": "docker-compose.yml",
  "service": "app",
  "workspaceFolder": "/workspace",
  "features": {
    "ghcr.io/devcontainers/features/node:1": {
      "version": "22"
    },
    "ghcr.io/devcontainers/features/git:1": {},
    "ghcr.io/devcontainers/features/github-cli:1": {}
  },
  "customizations": {
    "vscode": {
      "extensions": [
        "dbaeumer.vscode-eslint",
        "esbenp.prettier-vscode",
        "ms-vscode.vscode-typescript-next",
        "bradlc.vscode-tailwindcss"
      ],
      "settings": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "esbenp.prettier-vscode"
      }
    }
  },
  "postCreateCommand": "npm install",
  "remoteUser": "node",
  "forwardPorts": [3000, 5432],
  "portsAttributes": {
    "3000": { "label": "App Server", "onAutoForward": "notify" },
    "5432": { "label": "PostgreSQL", "onAutoForward": "silent" }
  }
}

Solving Common DevContainer Issues with Claude Code

If your DevContainer won't start, paste the error message directly into Claude Code:

claude "My DevContainer won't start with this error. Please identify the cause and fix:
[error] failed to solve: failed to read dockerfile: open .devcontainer/Dockerfile: no such file or directory"

Claude Code will immediately identify the problem and propose either generating the missing Dockerfile or fixing the devcontainer.json.


Multi-Stage Builds — Minimizing Your Production Image

Why Multi-Stage Builds Matter

A Node.js app packaged naively into Docker — including node_modules — can easily reach several gigabytes. Production environments need lightweight images containing only the built artifacts.

Multi-stage builds separate the build environment from the runtime environment, reducing production images to under 100MB.

Generating a Multi-Stage Dockerfile with Claude Code

claude "Create a multi-stage Dockerfile for a Next.js 15 app with:
- Build stage: node:22-alpine base
- Production stage: node:22-alpine (distroless optional)
- Non-root user for security
- Minimal setup using .next/standalone
- ARG to accept NODE_ENV"

Example generated Dockerfile:

# ──────────────────────────────────
# Stage 1: Install dependencies
# ──────────────────────────────────
FROM node:22-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
 
# Copy only package files first (maximizes cache hits)
COPY package.json package-lock.json* ./
RUN npm ci --only=production --ignore-scripts
 
# ──────────────────────────────────
# Stage 2: Build
# ──────────────────────────────────
FROM node:22-alpine AS builder
WORKDIR /app
 
COPY --from=deps /app/node_modules ./node_modules
COPY . .
 
# Assumes output: 'standalone' is set in next.config.ts
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
 
# ──────────────────────────────────
# Stage 3: Production runner (minimal size)
# ──────────────────────────────────
FROM node:22-alpine AS runner
WORKDIR /app
 
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
 
# Security: create a non-root user
RUN addgroup --system --gid 1001 nodejs && \
    adduser --system --uid 1001 nextjs
 
# Copy only the files needed for standalone output
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
 
USER nextjs
 
EXPOSE 3000
 
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
 
CMD ["node", "server.js"]

This Dockerfile keeps the final image size to approximately 80–120MB — about a 90% reduction compared to a development image that includes node_modules.

Verifying Image Size

# Build and check
docker build -t myapp:prod .
docker images myapp
 
# Expected output:
# REPOSITORY   TAG    IMAGE ID       CREATED         SIZE
# myapp        prod   a1b2c3d4e5f6   2 minutes ago   118MB

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
If you've been stuck on DevContainer configuration, you'll be able to set up a seamless Claude Code integration environment starting today
You'll learn multi-stage builds, Docker Compose, and security hardening patterns that you can apply directly to your own projects
You'll be able to eliminate manual deployment work by building a GitHub Actions × Docker × Claude Code automation pipeline
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Claude Code2026-06-14
Before Per-PR CI Burns Through Your Monthly Credits: A Three-Layer Guard for Claude Code GitHub Actions
From June 15, Claude Code GitHub Actions bills against non-rolling monthly credits. Run a review on every PR and you can drain the month in the first week. Here is a three-layer guard — when to run, how heavy one run can get, and making spend visible — with working workflows.
Claude Code2026-04-07
An Implementation Notebook for Shipping Android/Kotlin Apps to Google Play with Claude Code
A production notebook from years of running an indie Android app business. Compose × Hilt × Room design calls, ProGuard crash triage, and a 14-item pre-release checklist that goes in front of every Google Play AAB upload.
Claude Code2026-04-07
Claude Code × Python FastAPI in Production — Architecture, pytest, and Docker Deployment
Building production-ready Python FastAPI servers with Claude Code as an AI pair programmer — Pydantic v2, pytest automation, Docker, and CI/CD, with working code at each step.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →