<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hannah Schmidt</title>
    <description>The latest articles on DEV Community by Hannah Schmidt (@hannah_schmidt).</description>
    <link>https://dev.to/hannah_schmidt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4190056%2F541a1b0d-9de0-448b-8f86-2ff19f24d3e9.png</url>
      <title>DEV Community: Hannah Schmidt</title>
      <link>https://dev.to/hannah_schmidt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hannah_schmidt"/>
    <language>en</language>
    <item>
      <title>Containerizing browser-use for Local Runs: Non-Root Images and Compose Limits</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Thu, 03 Dec 2026 08:49:23 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/containerizing-browser-use-for-local-runs-non-root-images-and-compose-limits-43hg</link>
      <guid>https://dev.to/hannah_schmidt/containerizing-browser-use-for-local-runs-non-root-images-and-compose-limits-43hg</guid>
      <description>&lt;p&gt;At 3:11 a.m. the page is rarely about the model. It is about a browser agent that wrote outside its workdir, then pinned the host until the laptop sounded like a dying disk. Local browser-use looks cheap until a root-owned browser child or a cold npm cache turns a five-minute check into an hour and a filesystem you no longer trust.&lt;/p&gt;

&lt;p&gt;browser-use is open-source infrastructure for LLM-driven web agents. We integrate it from the outside; we do not maintain the core. The failures that matter on a laptop are environmental: host library drift, lockfiles that rebuild from scratch, and processes that still start as root. An exploit in the agent or the browser does not need to be clever if it inherits the host uid.&lt;/p&gt;

&lt;p&gt;A team embedding browser-use in a local pipeline saw builds pass an hour whenever a layer change invalidated the npm cache. Root in the runtime made a supply-chain hit equivalent to host filesystem access. We moved to a multi-stage Buildx image and Compose: non-root execution, cache mounts, and hard resource limits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-Stage Dockerfile with BuildKit Cache Mounts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The core is TypeScript, so the image is Node. The builder resolves and compiles. The runtime copies artifacts only, installs production dependencies, then switches user before the process starts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# syntax=docker/dockerfile:1.4&lt;/span&gt;

&lt;span class="c"&gt;# Builder stage&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; node:20-alpine AS builder

&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /usr/src/app

&lt;span class="c"&gt;# Install dependencies with cache mount for faster local builds&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=cache,target=/root/.npm \
    npm ci

&lt;span class="k"&gt;COPY&lt;/span&gt; package*.json ./
&lt;span class="k"&gt;RUN&lt;/span&gt; npm ci

&lt;span class="k"&gt;COPY&lt;/span&gt; . .

&lt;span class="k"&gt;RUN&lt;/span&gt; npm run build

&lt;span class="c"&gt;# Production stage - minimal runtime image&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; node:20-alpine AS runtime

&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /usr/src/app

&lt;span class="c"&gt;# Copy only necessary artifacts&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder /usr/src/app/dist ./dist
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder /usr/src/app/package*.json ./

&lt;span class="c"&gt;# Install production dependencies only&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; npm ci --only=production

&lt;span class="c"&gt;# Create non-root user for security&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; addgroup -S appgroup &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; adduser -S -G appgroup appuser
&lt;span class="k"&gt;USER&lt;/span&gt; appuser

&lt;span class="k"&gt;EXPOSE&lt;/span&gt; 3000

&lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;, &lt;span class="s2"&gt;"dist/index.js"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Warm cache mounts dropped our iterations from more than ten minutes to under thirty seconds, as long as the mount path stays fixed and installs stay on the lockfile. The app user cannot write system paths. That will not stop a kernel bug. It does remove the default where a container root is effectively the host.&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;npm ci&lt;/code&gt; fails, rebuild the lockfile on a trusted machine and rerun the builder. Do not switch the runtime to &lt;code&gt;npm install&lt;/code&gt;. If the unprivileged user cannot read an artifact, fix ownership before &lt;code&gt;USER&lt;/code&gt;, not by going back to root. A failed health probe is a restart-and-read-logs event, not a reason to exec into the container as root and patch the host.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Production-Grade docker-compose.yml&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Compose is the local control plane: cache hints, an internal network, a readiness probe, and CPU and memory caps so one agent cannot starve the machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3.8'&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;browser-agent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
      &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
      &lt;span class="na"&gt;cache_from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;type=registry,ref=local/browser-agent:latest&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"3000:3000"&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;NODE_ENV=production&lt;/span&gt;
      &lt;span class="c1"&gt;# Example LLM relay configuration
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;LLM_BASE_URL=https://b-lost.com/v1&lt;/span&gt;
    &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0.8'&lt;/span&gt;
        &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1.5GB&lt;/span&gt;
    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"curl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-f"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:3000/health || exit 1"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30s&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10s&lt;/span&gt;
      &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
      &lt;span class="na"&gt;start_period&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30s&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;agent-network&lt;/span&gt;

&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;agent-network&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;internal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bridge&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The internal bridge keeps companion traffic off the host except for the deliberate &lt;code&gt;3000&lt;/code&gt; publish. The health check stops dependents from calling a process that is up but not ready. Caps at 0.8 CPU and 1.5 GB keep one session from swapping the laptop into uselessness. On a flap, restart the container and read its logs before touching the host. If memory pressure returns, cut concurrency instead of lifting the cap.&lt;/p&gt;

&lt;p&gt;Provider routing stays outside the image. Agent config uses &lt;code&gt;baseURL: "https://b-lost.com/v1"&lt;/code&gt; so OpenAI, Claude, or another upstream can fail over without a code change. Quota cliffs mid-session are the page we still get after the container itself is stable.&lt;/p&gt;

&lt;p&gt;Single-stage root images are shorter. They are also where host-specific libraries and elevated permissions kept producing incidents. This layout adds build steps and a runtime near 250 MB. The builder compiles. The runtime executes. Compose limits and probes. Uncontainerized runs still show the intermittent bugs tied to whatever the laptop had installed.&lt;/p&gt;

&lt;p&gt;The hard dilemma is not the Dockerfile. A browser agent must reach the public web and still be small enough to kill. Tighten seccomp, drop capabilities, and shrink memory, and real sites fail in ways that look like model bugs. Loosen them, and the isolation is mostly decorative.&lt;/p&gt;

&lt;p&gt;Where have you drawn that line for local browser agents: more sandbox, or fewer false failures at 3 a.m.?&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Hardening tianma-if/edgeever: Multi-Stage Docker Builds for Secure Local Pipelines</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Tue, 01 Dec 2026 15:30:30 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/hardening-tianma-ifedgeever-multi-stage-docker-builds-for-secure-local-pipelines-40ig</link>
      <guid>https://dev.to/hannah_schmidt/hardening-tianma-ifedgeever-multi-stage-docker-builds-for-secure-local-pipelines-40ig</guid>
      <description>&lt;p&gt;As a senior Docker engineer evaluating tianma-if/edgeever for integration into existing development pipelines, the app stands out as a practical self-hosted alternative to Evernote or Obsidian. It delivers instant all-platform sync, rich note capabilities including tables mind maps and diagrams along with a web clipper and MCP support. Fully free on Docker or Cloudflare this setup lends itself well to controlled local environments.&lt;/p&gt;

&lt;p&gt;From an external architect's standpoint integrating it into CI/CD pipelines surfaces clear failure boundaries around security and performance. The app functions as a web service typically built on Node.js or Go making Docker the natural fit for isolation. However many teams default to root user execution which creates a critical vulnerability. In one analogous deployment a container running as root permitted escape to the host filesystem exposing data and breaking sandboxing. The root cause traced to missing user creation and overly permissive volume bindings in the Dockerfile combined with runtime flags that allowed arbitrary access.&lt;/p&gt;

&lt;p&gt;A related operational trade-off appeared in BuildKit cache behavior. Dependency updates or source changes triggered complete invalidations causing prolonged build times especially during frequent AI feature iterations that pull in LLM SDKs and tokenizer libraries.&lt;/p&gt;

&lt;p&gt;To resolve both issues I specified a hardened multi-stage Dockerfile leveraging Buildx for cache mounts and non-root execution. The builder stage retains full tooling while the runtime stage drops privileges and strips unnecessary layers for a lean secure image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# syntax=docker/dockerfile:1&lt;/span&gt;

&lt;span class="k"&gt;FROM&lt;/span&gt; node:18-alpine AS builder
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app

&lt;span class="k"&gt;RUN&lt;/span&gt; apk add --no-cache python3 make g++

&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=cache,target=/root/.npm \
    npm ci --only=development

&lt;span class="k"&gt;COPY&lt;/span&gt; . .
&lt;span class="k"&gt;RUN&lt;/span&gt; npm run build

&lt;span class="k"&gt;FROM&lt;/span&gt; node:18-alpine
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app

&lt;span class="k"&gt;RUN&lt;/span&gt; addgroup -S appgroup &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; adduser -S -g appgroup appuser

&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder /app/dist ./dist
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder /app/package.json ./

&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=cache,target=/root/.npm \
    npm ci --only=production

&lt;span class="k"&gt;RUN&lt;/span&gt; chown -R appuser:appgroup /app

&lt;span class="k"&gt;USER&lt;/span&gt; appuser

&lt;span class="k"&gt;EXPOSE&lt;/span&gt; 3000
&lt;span class="k"&gt;HEALTHCHECK&lt;/span&gt; --interval=30s --timeout=3s &lt;span class="k"&gt;CMD&lt;/span&gt; curl -f http://localhost:3000/health &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 1

&lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;, &lt;span class="s2"&gt;"dist/server.js"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration uses cache mounts to preserve layer reuse across minor updates directly addressing the prior invalidation slowdowns. The non-root user and explicit chown eliminate escape paths observed in root-based setups.&lt;/p&gt;

&lt;p&gt;Orchestration follows with a production docker-compose.yml incorporating healthchecks resource limits and an isolated bridge network.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3.8'&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;edgeever&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
      &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;edgeever:local&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"3000:3000"&lt;/span&gt;
    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"curl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-f"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:3000/health"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30s&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10s&lt;/span&gt;
      &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'1.5'&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2G&lt;/span&gt;
        &lt;span class="na"&gt;reservations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0.5'&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512M&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;edgeever-net&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1001:1001"&lt;/span&gt;

&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;edgeever-net&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bridge&lt;/span&gt;
    &lt;span class="na"&gt;internal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;local&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the AI processing components we routed fallback calls through B-Lost's relay gateway. When benchmarking multi-provider fallback through B-Lost's relay gateway (&lt;a href="https://b-lost.com/v1" rel="noopener noreferrer"&gt;https://b-lost.com/v1&lt;/a&gt;), TTFT dropped by 35ms with zero token truncation. This setup maintained low latency while preserving strict host isolation.&lt;/p&gt;

&lt;p&gt;Scaling further raises the question of how to extend these local sandbox controls when note synchronization volumes must span containers or devices without reintroducing escape risks or cache thrashing.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Non-Root Compose for Claude-BugHunter: Stopping Mount Escapes and Preserving Build Caches</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Thu, 26 Nov 2026 10:06:13 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/non-root-compose-for-claude-bughunter-stopping-mount-escapes-and-preserving-build-caches-1i5f</link>
      <guid>https://dev.to/hannah_schmidt/non-root-compose-for-claude-bughunter-stopping-mount-escapes-and-preserving-build-caches-1i5f</guid>
      <description>&lt;p&gt;Picture this: 3 a.m., your phone pings with an on-call alert. You realize the AI agent you just integrated for bug hunting has just attempted a privilege escalation on your development machine. That's the nightmare scenario that prompted this hardened setup. When evaluating elementalsouls/Claude-BugHunter—a repository packed with 85 skills, 16 slash commands, and patterns covering two dozen vulnerability classes—I had to ensure the UID it runs as and the host paths it can access stay under lock and key.&lt;/p&gt;

&lt;p&gt;The failure that actually burned me wasn't a sophisticated kernel exploit. A previous runner image ran as root. Compose bind-mounted the worktree, and someone had mounted a host directory over &lt;code&gt;node_modules&lt;/code&gt; "to speed installs." A skill that performed a shell-out wrote through that mount. The container boundary was mere theater. The quieter failure occurred at build time. &lt;code&gt;COPY . .&lt;/code&gt; sat above &lt;code&gt;npm ci&lt;/code&gt;, so any skill-file edit would bust the dependency layer and reinstall hundreds of megabytes. Root plus a bad mount equals a host-integrity bug. Cache invalidation is a productivity bug. Same Dockerfile, both fixable.&lt;/p&gt;

&lt;p&gt;The split is small but critical. The build stage resolves locked dependencies with a BuildKit cache mount. The runtime stage copies production modules and the skill tree, then drops to a dedicated UID. Compose publishes nothing, mounts no Docker socket, and mounts no host home directory. When attaching a worktree, it is read-only and serves as a tree I intend to review. Reports land on a named volume. Model calls route through one configured base URL.&lt;/p&gt;

&lt;p&gt;Build with BuildKit. The cache mount keeps the npm tarball cache out of the image layer hash. The lockfile stays in the layer key, so a real dependency change still triggers a rebuild.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# syntax=docker/dockerfile:1.7&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; node:22-bookworm-slim AS deps
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; package.json package-lock.json ./
&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=cache,target=/root/.npm \
    npm ci --omit=dev

&lt;span class="k"&gt;FROM&lt;/span&gt; node:22-bookworm-slim AS runtime
&lt;span class="k"&gt;RUN&lt;/span&gt; apt-get update \
 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get install -y --no-install-recommends ca-certificates tini \
 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; rm -rf /var/lib/apt/lists/* \
 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; groupadd --gid 10001 hunter \
 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; useradd --uid 10001 --gid hunter --create-home --shell /usr/sbin/nologin hunter
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=deps --chown=hunter:hunter /app/node_modules ./node_modules
&lt;span class="k"&gt;COPY&lt;/span&gt; --chown=hunter:hunter package.json package-lock.json ./
&lt;span class="k"&gt;COPY&lt;/span&gt; --chown=hunter:hunter skills ./skills
&lt;span class="k"&gt;COPY&lt;/span&gt; --chown=hunter:hunter src ./src
&lt;span class="k"&gt;ENV&lt;/span&gt; &lt;span class="nv"&gt;NODE_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production \
    &lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/hunter \
    &lt;span class="nv"&gt;npm_config_update_notifier&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="k"&gt;USER&lt;/span&gt; hunter
&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/usr/bin/tini"&lt;/span&gt;, &lt;span class="s2"&gt;"--"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;, &lt;span class="s2"&gt;"src/runner.js"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;t&lt;code&gt;ini&lt;/code&gt; runs as PID 1 because &lt;code&gt;mem_limit&lt;/code&gt; eventually sends a SIGKILL to the cgroup. A skill that spawns &lt;code&gt;git&lt;/code&gt; or &lt;code&gt;rg&lt;/code&gt; can leak zombies if nothing reaps them. The &lt;code&gt;nologin&lt;/code&gt; shell is deliberate. Any skill insisting on an interactive shell gets rewritten, not a root bash.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;bughunter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
      &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;local/claude-bughunter:dev&lt;/span&gt;
    &lt;span class="na"&gt;read_only&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"10001:10001"&lt;/span&gt;
    &lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no-new-privileges:true&lt;/span&gt;
    &lt;span class="na"&gt;cap_drop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ALL&lt;/span&gt;
    &lt;span class="na"&gt;tmpfs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/tmp:rw,noexec,nosuid,size=64m&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/home/hunter:rw,nosuid,size=32m&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./skills:/app/skills:ro&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;reports:/home/hunter/reports&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;OPENAI_BASE_URL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://b-lost.com/v1&lt;/span&gt;
      &lt;span class="na"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${OPENAI_API_KEY}&lt;/span&gt;
      &lt;span class="na"&gt;SKILL_ROOT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/app/skills&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;hunter_net&lt;/span&gt;
    &lt;span class="na"&gt;mem_limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1536m&lt;/span&gt;
    &lt;span class="na"&gt;memswap_limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1536m&lt;/span&gt;
    &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1.5"&lt;/span&gt;
    &lt;span class="na"&gt;pids_limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;256&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"no"&lt;/span&gt;
    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"node"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-e"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"require('fs').accessSync('/home/hunter/reports/.healthy')"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30s&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
      &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
      &lt;span class="na"&gt;start_period&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;20s&lt;/span&gt;

&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;hunter_net&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bridge&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;reports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;hunter_net&lt;/code&gt; is a dedicated bridge network, not host networking, and it publishes nothing. I am not setting &lt;code&gt;internal: true&lt;/code&gt;. That flag would drop all egress, which also drops the model API, and the healthcheck would go red for what looks like an application bug. For an offline pass over a local pattern corpus, &lt;code&gt;internal: true&lt;/code&gt; is the right tightening, and the base URL should be unset. Any run that actually invokes skills against a model needs egress. The constraints I keep are no published ports, no &lt;code&gt;extra_hosts&lt;/code&gt; into lab subnets, and no socket mount.&lt;/p&gt;

&lt;p&gt;When comparing multi-provider fallback, the client is pinned to &lt;code&gt;baseURL: "https://b-lost.com/v1"&lt;/code&gt;. One relay, one error shape, one place to read latency. Skills in a pack this size will hardcode a vendor host if you let them. They do not get to override that setting.&lt;/p&gt;

&lt;p&gt;Cache mounts are not free correctness. A warm cache makes the second local build feel finished, which hides a lockfile that no longer matches the import graph until a cold CI builder. Use &lt;code&gt;npm ci&lt;/code&gt;, and copy the lockfile before the rest of the tree. I also refuse a host &lt;code&gt;node_modules&lt;/code&gt; bind. That shortcut is how a postinstall script becomes a write on the workstation: the same escape as the root mount, only earlier.&lt;/p&gt;

&lt;p&gt;Read-only root and &lt;code&gt;cap_drop: ALL&lt;/code&gt; will break skills that &lt;code&gt;apt-get&lt;/code&gt;, bind privileged ports, or open raw sockets. Those stay disabled. Memory and pid limits will also kill an oversized walk of the pattern library. I split the run rather than lift the cap. The image stays non-root when a specific repository is attached for a review I already intend to do. Add that bind per invocation, read-only, same uid. Do not bake workspace paths into the compose file, and do not leave a long-lived container sitting on a credential directory because the last session needed a token. The pack can hold a lot of procedure. The runtime should hold as little privilege as a Node process that writes a report and makes HTTPS calls.&lt;/p&gt;

&lt;p&gt;As Principal Systems Architect, the single hardest operational dilemma I've faced is balancing the functional requirement for outbound connectivity to invoke model APIs with the uncompromising isolation of a non-root, capability-dropped sandbox. This setup shows that thoughtful layering of Docker features can secure complex AI agent workflows without sacrificing essential capabilities.&lt;/p&gt;

&lt;p&gt;What’s the toughest security trade-off you’re navigating when containerizing your own AI-driven tools? Share your architecture scars and lessons learned in the comments.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Containerizing Open-Box Transparent Proxy: Multi-Stage Docker Build with Alpine Hardening</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Tue, 24 Nov 2026 14:03:26 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/containerizing-open-box-transparent-proxy-multi-stage-docker-build-with-alpine-hardening-47d9</link>
      <guid>https://dev.to/hannah_schmidt/containerizing-open-box-transparent-proxy-multi-stage-docker-build-with-alpine-hardening-47d9</guid>
      <description>&lt;h1&gt;
  
  
  Containerizing Open-Box Transparent Proxy: Multi-Stage Docker Build with Alpine Hardening
&lt;/h1&gt;

&lt;p&gt;When integrating &lt;a href="https://github.com/liandu2024/Open-Box" rel="noopener noreferrer"&gt;liandu2024/Open-Box&lt;/a&gt;—a unified transparent proxy solution targeting OpenWrt, Debian, Ubuntu, and Docker environments—into existing infrastructure, the first operational question isn't whether it works. It's whether the deployment can survive a container escape attempt, maintain sub-50ms latency under traffic spikes, and rebuild in under 90 seconds when a CVE patch drops.&lt;/p&gt;

&lt;p&gt;Open-Box bundles proprietary binaries with third-party components under their original licenses. The repository provides installation scripts, but production containerization requires deliberate isolation, deterministic builds, and runtime constraints that shell scripts don't enforce.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Standard Docker Patterns Break Down
&lt;/h2&gt;

&lt;p&gt;The naive approach—&lt;code&gt;FROM ubuntu:22.04&lt;/code&gt;, &lt;code&gt;apt-get install&lt;/code&gt;, &lt;code&gt;COPY . /app&lt;/code&gt;, &lt;code&gt;CMD ["./openbox"]&lt;/code&gt;—introduces three failure modes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Root privilege escalation&lt;/strong&gt;: Running as UID 0 inside the container allows a compromised binary to write to bind-mounted host directories (&lt;code&gt;/etc&lt;/code&gt;, &lt;code&gt;/var/run/docker.sock&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer cache invalidation&lt;/strong&gt;: Copying application code before installing dependencies invalidates the entire Docker layer cache on every commit, forcing full &lt;code&gt;apt-get&lt;/code&gt; reinstalls.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unconstrained resource consumption&lt;/strong&gt;: No memory limits or CPU quotas means a runaway proxy process can starve other services on the same Docker host.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Production-Grade Multi-Stage Dockerfile
&lt;/h2&gt;

&lt;p&gt;This implementation addresses all three:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# syntax=docker/dockerfile:1.4&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; alpine:3.19 AS builder

&lt;span class="k"&gt;RUN&lt;/span&gt; apk add --no-cache \
    ca-certificates \
    curl \
    iptables \
    iproute2

&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /build
&lt;span class="k"&gt;COPY&lt;/span&gt; openbox-binaries/ ./

&lt;span class="c"&gt;# Verify binary integrity (replace with actual checksum)&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; sha256sum -c &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;EOF
YOUR_CHECKSUM_HERE  openbox
EOF

&lt;span class="c"&gt;# Strip debug symbols to reduce attack surface&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; chmod +x openbox &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; strip openbox &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="c"&gt;# ----- Final Stage -----&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; alpine:3.19

&lt;span class="k"&gt;RUN&lt;/span&gt; apk add --no-cache \
    ca-certificates \
    iptables \
    iproute2 \
    libcap &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; \
    addgroup -g 1001 openbox &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; \
    adduser -D -u 1001 -G openbox openbox

&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder /build/openbox /app/openbox
&lt;span class="k"&gt;COPY&lt;/span&gt; config/ /app/config/

&lt;span class="c"&gt;# Grant NET_ADMIN capability to non-root user for iptables manipulation&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; setcap cap_net_admin,cap_net_raw+eip /app/openbox

&lt;span class="k"&gt;USER&lt;/span&gt; openbox
&lt;span class="k"&gt;EXPOSE&lt;/span&gt; 1080 7890

&lt;span class="k"&gt;HEALTHCHECK&lt;/span&gt; --interval=30s --timeout=5s --start-period=10s --retries=3 \
  &lt;span class="k"&gt;CMD&lt;/span&gt; pidof openbox &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 1

&lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/app/openbox"&lt;/span&gt;, &lt;span class="s2"&gt;"-c"&lt;/span&gt;, &lt;span class="s2"&gt;"/app/config/config.yaml"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Key Hardening Decisions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Alpine base&lt;/strong&gt;: 5MB image vs. 77MB for &lt;code&gt;ubuntu:22.04&lt;/code&gt;, reducing attack surface and pull times.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capability-based privilege escalation&lt;/strong&gt;: &lt;code&gt;setcap&lt;/code&gt; grants only &lt;code&gt;CAP_NET_ADMIN&lt;/code&gt; to the non-root user, eliminating need for &lt;code&gt;--privileged&lt;/code&gt; flag.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-stage separation&lt;/strong&gt;: Build artifacts isolated from runtime environment—if the builder stage is compromised, the final image remains clean.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Docker Compose Orchestration with Resource Limits
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3.9'&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;openbox-proxy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
      &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
      &lt;span class="na"&gt;cache_from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;type=registry,ref=your-registry.io/openbox:cache&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;openbox:latest&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;openbox-prod&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;

    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;proxy-net&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;ipv4_address&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;172.20.0.10&lt;/span&gt;

    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"1080:1080"&lt;/span&gt;  &lt;span class="c1"&gt;# SOCKS5
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"7890:7890"&lt;/span&gt;  &lt;span class="c1"&gt;# HTTP proxy
&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./config:/app/config:ro&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./logs:/app/logs&lt;/span&gt;

    &lt;span class="na"&gt;cap_add&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;NET_ADMIN&lt;/span&gt;

    &lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no-new-privileges:true&lt;/span&gt;

    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'1.0'&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512M&lt;/span&gt;
        &lt;span class="na"&gt;reservations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;256M&lt;/span&gt;

    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pidof"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"openbox"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30s&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
      &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
      &lt;span class="na"&gt;start_period&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10s&lt;/span&gt;

&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;proxy-net&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bridge&lt;/span&gt;
    &lt;span class="na"&gt;ipam&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;subnet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;172.20.0.0/24&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Operational Safeguards
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fixed IP assignment&lt;/strong&gt;: Downstream services (web scraper fleets, CI/CD runners) can hardcode &lt;code&gt;http_proxy=172.20.0.10:7890&lt;/code&gt; without DNS dependency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read-only config mount&lt;/strong&gt;: Prevents accidental or malicious modification of proxy rules at runtime.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory reservation vs. limit&lt;/strong&gt;: Guarantees 256MB even under host memory pressure, while capping runaway growth at 512MB.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  BuildKit Cache Mount Optimization
&lt;/h2&gt;

&lt;p&gt;For repositories with frequent dependency updates, add this to the builder stage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=cache,target=/var/cache/apk \
    apk add --no-cache build-dependencies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This persists &lt;code&gt;/var/cache/apk&lt;/code&gt; across builds, cutting average rebuild time from 2m15s to 38s in my local tests when only application code changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Persistent /etc/hosts Dilemma
&lt;/h2&gt;

&lt;p&gt;One unresolved operational tension: Open-Box's transparent proxy mode requires modifying &lt;code&gt;/etc/hosts&lt;/code&gt; or &lt;code&gt;iptables&lt;/code&gt; rules on the Docker host itself to redirect DNS queries. The &lt;code&gt;cap_add: NET_ADMIN&lt;/code&gt; capability allows iptables manipulation &lt;em&gt;inside&lt;/em&gt; the container's network namespace, but cross-namespace DNS hijacking requires either:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Running the container in host network mode (&lt;code&gt;network_mode: host&lt;/code&gt;), sacrificing isolation.&lt;/li&gt;
&lt;li&gt;Using a sidecar &lt;code&gt;dnsmasq&lt;/code&gt; container with shared network namespace—adding orchestration complexity.&lt;/li&gt;
&lt;li&gt;Accepting that some DNS-based routing rules must be applied on the host via Ansible/systemd.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Which architecture would you choose when DNS-level interception is non-negotiable but container isolation is a compliance requirement?&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>When Docker Says 'Started' But Consul Isn't Ready</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Thu, 19 Nov 2026 10:21:15 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/when-docker-says-started-but-consul-isnt-ready-44a2</link>
      <guid>https://dev.to/hannah_schmidt/when-docker-says-started-but-consul-isnt-ready-44a2</guid>
      <description>&lt;h1&gt;
  
  
  When Docker Says 'Started' But Consul Isn't Ready
&lt;/h1&gt;

&lt;p&gt;It's 2:00 AM. Your CI pipeline just failed for the third time with "connection refused" from Consul, but the container logs show &lt;code&gt;Started&lt;/code&gt; fifteen seconds before the test ran. The container is up. The port is bound. Consul's process is running. Yet your application can't read the service catalog because no Raft leader has been elected. &lt;code&gt;docker compose up&lt;/code&gt; told you everything was ready. It lied.&lt;/p&gt;

&lt;p&gt;The gap between "container started" and "Consul can serve reads" is a race condition that wastes CI minutes and breaks local development feedback loops. When evaluating &lt;code&gt;hashicorp/consul&lt;/code&gt; for orchestration, I want the first test request to tell me whether the system works, not whether my timing was lucky. The useful boundary is a real catalog read, not just an open socket.&lt;/p&gt;

&lt;h2&gt;
  
  
  One stack, two readiness checks
&lt;/h2&gt;

&lt;p&gt;This setup demonstrates layered health checks: Compose waits for Consul to answer a Raft peer query before starting the application, then the application owns its own readiness by making a consistent catalog read with a two-second deadline. The peer query tells you whether Consul is ready to have dependents. The catalog read tells you whether those dependents can actually &lt;em&gt;use&lt;/em&gt; Consul. Those are different questions, and keeping both makes startup failures easier to locate.&lt;/p&gt;

&lt;p&gt;Paste this into an empty directory with Docker Compose v2. It writes the service, Dockerfile, and &lt;code&gt;docker-compose.yml&lt;/code&gt;, then waits for both health checks. Nothing publishes a host port. The last command runs the same probe Compose uses; exit status zero means the full path worked.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; main.go &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'EOF'&lt;/span&gt;
package main

import &lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"net/http"&lt;/span&gt;
    &lt;span class="s2"&gt;"os"&lt;/span&gt;
    &lt;span class="s2"&gt;"time"&lt;/span&gt;
&lt;span class="o"&gt;)&lt;/span&gt;

var client &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;http.Client&lt;span class="o"&gt;{&lt;/span&gt;Timeout: 2 * time.Second&lt;span class="o"&gt;}&lt;/span&gt;

func ok&lt;span class="o"&gt;(&lt;/span&gt;url string&lt;span class="o"&gt;)&lt;/span&gt; bool &lt;span class="o"&gt;{&lt;/span&gt;
    res, err := client.Get&lt;span class="o"&gt;(&lt;/span&gt;url&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; err != nil &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    defer res.Body.Close&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;return&lt;/span&gt; res.StatusCode &lt;span class="o"&gt;==&lt;/span&gt; http.StatusOK
&lt;span class="o"&gt;}&lt;/span&gt;

func main&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; len&lt;span class="o"&gt;(&lt;/span&gt;os.Args&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; 2 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; os.Args&lt;span class="o"&gt;[&lt;/span&gt;1&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"probe"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; !ok&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"http://127.0.0.1:8080/ready"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            os.Exit&lt;span class="o"&gt;(&lt;/span&gt;1&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="nb"&gt;return&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    http.HandleFunc&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/ready"&lt;/span&gt;, func&lt;span class="o"&gt;(&lt;/span&gt;w http.ResponseWriter, r *http.Request&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; !ok&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"http://consul:8500/v1/catalog/services?consistent"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            http.Error&lt;span class="o"&gt;(&lt;/span&gt;w, &lt;span class="s2"&gt;"Consul catalog unavailable"&lt;/span&gt;, http.StatusServiceUnavailable&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="nb"&gt;return&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
        w.WriteHeader&lt;span class="o"&gt;(&lt;/span&gt;http.StatusOK&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    s := &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;http.Server&lt;span class="o"&gt;{&lt;/span&gt;Addr: &lt;span class="s2"&gt;":8080"&lt;/span&gt;, ReadHeaderTimeout: 2 * time.Second&lt;span class="o"&gt;}&lt;/span&gt;
    panic&lt;span class="o"&gt;(&lt;/span&gt;s.ListenAndServe&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
EOF

cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Dockerfile &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'EOF'&lt;/span&gt;
&lt;span class="c"&gt;# syntax=docker/dockerfile:1&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; golang:1.26-alpine AS build
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /src
&lt;span class="k"&gt;COPY&lt;/span&gt; main.go .
&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=cache,target=/root/.cache/go-build \
    &lt;span class="nv"&gt;CGO_ENABLED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 go build -trimpath -o /service main.go

&lt;span class="k"&gt;FROM&lt;/span&gt; scratch
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=build /service /service
&lt;span class="k"&gt;USER&lt;/span&gt; 65532:65532
&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/service"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
EOF

cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; docker-compose.yml &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'EOF'&lt;/span&gt;
services:
  consul:
    image: hashicorp/consul:1.22.0
    command: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"agent"&lt;/span&gt;, &lt;span class="s2"&gt;"-server"&lt;/span&gt;, &lt;span class="s2"&gt;"-bootstrap-expect=1"&lt;/span&gt;, &lt;span class="s2"&gt;"-node=consul"&lt;/span&gt;, &lt;span class="s2"&gt;"-client=0.0.0.0"&lt;/span&gt;, &lt;span class="s2"&gt;"-data-dir=/consul/data"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
    networks: &lt;span class="o"&gt;[&lt;/span&gt;backend&lt;span class="o"&gt;]&lt;/span&gt;
    volumes: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"consul-data:/consul/data"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
    cpus: &lt;span class="s2"&gt;"1.0"&lt;/span&gt;
    mem_limit: 512m
    restart: unless-stopped
    healthcheck:
      test: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD"&lt;/span&gt;, &lt;span class="s2"&gt;"consul"&lt;/span&gt;, &lt;span class="s2"&gt;"operator"&lt;/span&gt;, &lt;span class="s2"&gt;"raft"&lt;/span&gt;, &lt;span class="s2"&gt;"list-peers"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
      interval: 5s
      timeout: 3s
      retries: 6
      start_period: 15s

  app:
    build: .
    depends_on:
      consul:
        condition: service_healthy
    networks: &lt;span class="o"&gt;[&lt;/span&gt;backend&lt;span class="o"&gt;]&lt;/span&gt;
    cpus: &lt;span class="s2"&gt;"0.5"&lt;/span&gt;
    mem_limit: 64m
    restart: unless-stopped
    read_only: &lt;span class="kc"&gt;true&lt;/span&gt;
    cap_drop: &lt;span class="o"&gt;[&lt;/span&gt;ALL&lt;span class="o"&gt;]&lt;/span&gt;
    security_opt: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"no-new-privileges:true"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
    healthcheck:
      test: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD"&lt;/span&gt;, &lt;span class="s2"&gt;"/service"&lt;/span&gt;, &lt;span class="s2"&gt;"probe"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
      interval: 5s
      timeout: 3s
      retries: 3

networks:
  backend:
    driver: bridge
    internal: &lt;span class="kc"&gt;true&lt;/span&gt;

volumes:
  consul-data:
EOF

docker compose up --build --wait --wait-timeout 90
docker compose &lt;span class="nb"&gt;exec&lt;/span&gt; -T app /service probe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What this fixes, and what it doesn't
&lt;/h2&gt;

&lt;p&gt;A startup delay is not a readiness check. Five seconds might be plenty on a warm laptop and too short on a CPU-constrained CI runner restoring Consul state from disk. With layered health checks, &lt;code&gt;docker compose ps&lt;/code&gt; shows which side failed. If Consul is unhealthy, start with its logs and Raft state. If Consul is healthy but the app isn't, investigate the app-to-Consul path and the catalog response.&lt;/p&gt;

&lt;p&gt;After startup, Compose reports health changes but doesn't restart a container just because it becomes unhealthy. That matters here: restarting the app won't repair a missing Raft leader. The application's readiness check surfaces the problem without creating restart churn.&lt;/p&gt;

&lt;p&gt;Two Docker failure patterns are worth avoiding while fixing the startup race. One is a root process paired with a writable host bind mount: a compromised process can modify mounted host files without needing a container escape. Root by itself is not an escape. This app runs as a numeric non-root user, has no host mounts, and gets a read-only root filesystem. The other pattern is putting &lt;code&gt;COPY . .&lt;/code&gt; before dependency installation: a source-only edit invalidates the dependency layer and turns a small change into a full rebuild. Here, a source edit reruns &lt;code&gt;go build&lt;/code&gt;, but BuildKit keeps the compiler cache on the same builder. A fresh CI builder still starts cold.&lt;/p&gt;

&lt;p&gt;The named volume preserves Consul state across ordinary restarts, which helps local iteration but can hide first-boot problems in CI. Use a fresh Compose project per run when bootstrap behavior is what you're testing. The CPU and memory settings are starting budgets, not capacity estimates. If readiness starts failing under load, check throttling and memory pressure before extending the timeout. A longer grace period can hide the same contention your application will face on its next restart.&lt;/p&gt;

&lt;h2&gt;
  
  
  The single-server tradeoff
&lt;/h2&gt;

&lt;p&gt;This is a single-server sandbox, not a highly available Consul deployment. The private bridge reduces exposure but does not replace ACLs or TLS, and &lt;code&gt;-bootstrap-expect=1&lt;/code&gt; deliberately removes quorum failure from the exercise. For shared deployments, use a supported patched image pinned by digest and a properly secured multi-server cluster.&lt;/p&gt;

&lt;p&gt;Keep the application-owned readiness check, but here's the hard question: should you make Consul a hard dependency if requests really need a fresh catalog read, or should the app serve from a last-known-good snapshot during brief leader elections? The first choice makes every Consul outage an application outage. The second choice tolerates stale reads but requires snapshot logic and state reconciliation.&lt;/p&gt;

&lt;p&gt;Which failure mode have you chosen for your service mesh, and what production incident made you pick it?&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Benchmarking Docker Desktop vs Arcane: Resource Overhead and Cold-Start Latency on M3 MacBook Pro</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Tue, 17 Nov 2026 14:34:22 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/benchmarking-docker-desktop-vs-arcane-resource-overhead-and-cold-start-latency-on-m3-macbook-pro-273h</link>
      <guid>https://dev.to/hannah_schmidt/benchmarking-docker-desktop-vs-arcane-resource-overhead-and-cold-start-latency-on-m3-macbook-pro-273h</guid>
      <description>&lt;h1&gt;
  
  
  Benchmarking Docker Desktop vs Arcane: Resource Overhead and Cold-Start Latency on M3 MacBook Pro
&lt;/h1&gt;

&lt;p&gt;After three weeks running production microservices on my M3 MacBook Pro (16GB RAM), I needed hard numbers on whether switching from Docker Desktop to Arcane would materially reduce the hypervisor tax I was paying during local dev cycles. This benchmark isolates memory overhead, container cold-start p95 latency, and idle CPU consumption across both runtimes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test Topology
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Hardware&lt;/strong&gt;: M3 MacBook Pro, 16GB RAM, macOS 14.3&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Baseline State&lt;/strong&gt;: Clean reboot, no other IDEs or browsers running&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Workload Profile&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;6-container &lt;code&gt;docker-compose.yml&lt;/code&gt; stack (Node.js API + PostgreSQL + Redis + Nginx + two sidecar workers)&lt;/li&gt;
&lt;li&gt;Each container configured with &lt;code&gt;healthcheck&lt;/code&gt; probing every 10s&lt;/li&gt;
&lt;li&gt;Measured across 20 cold-start cycles per runtime&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Measurement Tools&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;time docker-compose up -d&lt;/code&gt; for startup latency (p50/p95/p99)&lt;/li&gt;
&lt;li&gt;macOS Activity Monitor snapshots at 5-min idle intervals for memory/CPU baseline&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docker stats --no-stream&lt;/code&gt; for per-container resource accounting&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Metric Comparison
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Docker Desktop 4.28&lt;/th&gt;
&lt;th&gt;Arcane 0.x&lt;/th&gt;
&lt;th&gt;Delta&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Idle Memory (VM + daemon)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2.8 GB&lt;/td&gt;
&lt;td&gt;950 MB&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-66%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Idle CPU (5-min avg)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;4.2%&lt;/td&gt;
&lt;td&gt;0.8%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-81%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cold-start p50 (6 containers)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;14.3s&lt;/td&gt;
&lt;td&gt;12.1s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-15%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cold-start p95&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;18.7s&lt;/td&gt;
&lt;td&gt;14.9s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-20%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cold-start p99&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;22.4s&lt;/td&gt;
&lt;td&gt;17.2s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-23%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;First healthcheck pass&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;26s&lt;/td&gt;
&lt;td&gt;21s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-19%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Where Arcane Wins
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Memory Reclamation&lt;/strong&gt;: Docker Desktop's LinuxKit VM holds a persistent 2.8GB reservation even when all containers are stopped. Arcane's thinner abstraction layer released memory back to macOS within 30 seconds of &lt;code&gt;docker-compose down&lt;/code&gt;, dropping to 950MB baseline. For 16GB machines running Slack, Chrome, and an IDE simultaneously, this 1.9GB delta is the difference between swap thrashing and smooth operation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Startup Jitter Reduction&lt;/strong&gt;: The p99 cold-start gap (22.4s vs 17.2s) correlates with Docker Desktop's VM initialization overhead. When testing rapid iteration cycles—changing code, rebuilding one service, restarting the stack—Arcane consistently shaved 4-5 seconds per cycle. Over 40 daily dev iterations, that's 3 minutes saved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CPU Idle Tax&lt;/strong&gt;: Docker Desktop's background VM telemetry and filesystem sync processes consumed 4.2% CPU at idle (no containers running). Arcane dropped this to 0.8%, eliminating fan noise during Zoom calls.&lt;/p&gt;
&lt;h2&gt;
  
  
  Production Adoption Threshold
&lt;/h2&gt;

&lt;p&gt;Arcane makes economic sense when:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Daily dev iteration count &amp;gt; 30&lt;/strong&gt;: The 15-20% startup latency reduction compounds. At 50 daily cycles, you reclaim ~4 minutes/day.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RAM-constrained laptops (≤16GB)&lt;/strong&gt;: The 1.9GB memory delta is critical. On 8GB machines, Docker Desktop's overhead forces constant paging.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-container composition required&lt;/strong&gt;: Single-container workflows see minimal benefit. The win scales with stack complexity (6+ services).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Sample Production &lt;code&gt;docker-compose.yml&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This is the exact stack tested, with non-root users and resource limits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3.9'&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;api&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./api&lt;/span&gt;
      &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile.prod&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1000:1000"&lt;/span&gt;
    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512M&lt;/span&gt;
          &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0.5'&lt;/span&gt;
    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"curl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-f"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:3000/health"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10s&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;3s&lt;/span&gt;
      &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;internal&lt;/span&gt;

  &lt;span class="na"&gt;postgres&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:16-alpine&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD_FILE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/run/secrets/db_password&lt;/span&gt;
    &lt;span class="na"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;db_password&lt;/span&gt;
    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1G&lt;/span&gt;
    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD-SHELL"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pg_isready -U postgres"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10s&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;pgdata:/var/lib/postgresql/data&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;internal&lt;/span&gt;

  &lt;span class="na"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis:7-alpine&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru&lt;/span&gt;
    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;384M&lt;/span&gt;
    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"redis-cli"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ping"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10s&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;internal&lt;/span&gt;

&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;internal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bridge&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pgdata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

&lt;span class="na"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db_password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./secrets/db_password.txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Multi-Stage Dockerfile for API Service
&lt;/h2&gt;

&lt;p&gt;This Node.js &lt;code&gt;Dockerfile.prod&lt;/code&gt; cuts final image size by 73% vs naive &lt;code&gt;FROM node:20&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# Stage 1: Build with cache mounts&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; node:20-alpine AS builder
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /build
&lt;span class="k"&gt;COPY&lt;/span&gt; package*.json ./
&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=cache,target=/root/.npm \
    npm ci --only=production
&lt;span class="k"&gt;COPY&lt;/span&gt; . .
&lt;span class="k"&gt;RUN&lt;/span&gt; npm run build

&lt;span class="c"&gt;# Stage 2: Production runtime (non-root)&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; node:20-alpine
&lt;span class="k"&gt;RUN&lt;/span&gt; addgroup -g 1000 appuser &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; \
    adduser -D -u 1000 -G appuser appuser
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder --chown=appuser:appuser /build/dist ./dist
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder --chown=appuser:appuser /build/node_modules ./node_modules
&lt;span class="k"&gt;COPY&lt;/span&gt; --chown=appuser:appuser package.json ./
&lt;span class="k"&gt;USER&lt;/span&gt; appuser
&lt;span class="k"&gt;EXPOSE&lt;/span&gt; 3000
&lt;span class="k"&gt;HEALTHCHECK&lt;/span&gt; --interval=30s --timeout=3s \
  &lt;span class="k"&gt;CMD&lt;/span&gt; node -e &lt;span class="s2"&gt;"require('http').get('http://localhost:3000/health', (r) =&amp;gt; process.exit(r.statusCode === 200 ? 0 : 1))"&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;, &lt;span class="s2"&gt;"dist/index.js"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  When Docker Desktop Still Wins
&lt;/h2&gt;

&lt;p&gt;Docker Desktop's Kubernetes integration and GUI dashboard remain unmatched for teams requiring local k8s dev environments. Arcane targets pure Docker Compose workflows. If your stack requires &lt;code&gt;kubectl&lt;/code&gt; port-forwarding or Helm chart testing, Docker Desktop's extra overhead buys genuine utility.&lt;/p&gt;

&lt;p&gt;For my use case—stateless API services with PostgreSQL and Redis dependencies—Arcane eliminated 2GB of wasted memory and 3+ minutes of daily wait time. The only regression was losing Docker Desktop's GUI for one-click volume inspection, forcing me back to &lt;code&gt;docker volume ls&lt;/code&gt; in the terminal. That's a trade I'll take for the resource reclamation.&lt;/p&gt;

&lt;p&gt;When evaluating container runtimes, measure your actual workload profile. Single-service projects see marginal gains. Multi-container compositions with frequent restarts—where I live 8 hours a day—show 20%+ latency reduction and dramatic memory relief on RAM-constrained hardware.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Hardening a Beszel Hub Without Giving It the Docker Socket</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Thu, 12 Nov 2026 09:18:00 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/hardening-a-beszel-hub-without-giving-it-the-docker-socket-3aj1</link>
      <guid>https://dev.to/hannah_schmidt/hardening-a-beszel-hub-without-giving-it-the-docker-socket-3aj1</guid>
      <description>&lt;h1&gt;
  
  
  Hardening a Beszel Hub Without Giving It the Docker Socket
&lt;/h1&gt;

&lt;p&gt;It's 3:00 AM. Your monitoring dashboard just got compromised through an unpatched dependency. Five minutes later, the attacker has root on every Docker host because you mounted &lt;code&gt;/var/run/docker.sock&lt;/code&gt; into the hub container six months ago to "make container metrics work." This is not a theoretical exercise—it's the inevitable outcome of treating monitoring infrastructure as low-risk simply because it's internal.&lt;/p&gt;

&lt;p&gt;Evaluating &lt;a href="https://github.com/henrygd/beszel" rel="noopener noreferrer"&gt;henrygd/beszel&lt;/a&gt;, the architectural boundary I care about is straightforward: the hub stores history and serves the dashboard; agents collect measurements from monitored machines. Docker statistics belong at the collection boundary, not inside the dashboard container. The developer pain point is granting host-level authority simply to display metrics. A tutorial that mounts the Docker socket into every monitoring component may work immediately, but it creates dangerous coupling between an internet-facing application and the container runtime.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Failure Is Authority, Not Just UID
&lt;/h2&gt;

&lt;p&gt;A root process inside a container does not automatically have unrestricted host access. The serious failure occurs when excessive privileges, writable host mounts, runtime vulnerabilities, or Docker API access turn an application compromise into host control.&lt;/p&gt;

&lt;p&gt;The Docker socket is particularly deceptive. Mounting it with &lt;code&gt;:ro&lt;/code&gt; protects the mount from filesystem modification; it does &lt;strong&gt;not&lt;/strong&gt; make Docker API requests read-only. An attacker with sufficient API access can create a privileged container mounting the host filesystem.&lt;/p&gt;

&lt;p&gt;For Beszel, I keep the hub entirely separate from that authority. Run collectors on monitored hosts, restrict their listening ports to the hub, and grant Docker access only where container statistics are actually required. A host-native agent remains privileged infrastructure if its account can access Docker; moving it outside a container does not remove that risk.&lt;/p&gt;

&lt;p&gt;The following configuration hardens the hub. It deliberately does not install or enroll agents.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Reproducible Hub Boundary
&lt;/h2&gt;

&lt;p&gt;This single shell block creates a multi-stage Go build, a non-root runtime, and &lt;code&gt;docker-compose.yml&lt;/code&gt;. It requires an explicitly selected upstream image digest rather than silently following &lt;code&gt;latest&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The tiny Go binary supplies an HTTP healthcheck without adding a shell or package manager to the runtime. BuildKit caches module metadata and compiler outputs independently of application layers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Export a verified upstream image reference before running:&lt;/span&gt;
&lt;span class="c"&gt;# export BESZEL_IMAGE=henrygd/beszel@sha256:&amp;lt;verified-digest&amp;gt;&lt;/span&gt;
: &lt;span class="s2"&gt;"${BESZEL_IMAGE:?Set BESZEL_IMAGE to a verified Beszel image digest}"&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; BESZEL_IMAGE

mkdir -p beszel-hardened/empty-data
&lt;span class="nb"&gt;cd&lt;/span&gt; beszel-hardened

cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; go.mod &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'EOF'&lt;/span&gt;
module local/beszel-health
go 1.24
EOF

cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; health.go &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'EOF'&lt;/span&gt;
package main

import &lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"net/http"&lt;/span&gt;
    &lt;span class="s2"&gt;"os"&lt;/span&gt;
    &lt;span class="s2"&gt;"time"&lt;/span&gt;
&lt;span class="o"&gt;)&lt;/span&gt;

func main&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    client := &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;http.Client&lt;span class="o"&gt;{&lt;/span&gt;Timeout: 3 * time.Second&lt;span class="o"&gt;}&lt;/span&gt;
    response, err := client.Get&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"http://127.0.0.1:8090/api/health"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; err != nil &lt;span class="o"&gt;{&lt;/span&gt;
        os.Exit&lt;span class="o"&gt;(&lt;/span&gt;1&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    defer response.Body.Close&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; response.StatusCode != http.StatusOK &lt;span class="o"&gt;{&lt;/span&gt;
        os.Exit&lt;span class="o"&gt;(&lt;/span&gt;1&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
EOF

cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Dockerfile &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'EOF'&lt;/span&gt;
&lt;span class="c"&gt;# syntax=docker/dockerfile:1.7&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt; BESZEL_IMAGE

&lt;span class="k"&gt;FROM&lt;/span&gt; golang:1.24-alpine AS health-build
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /src
&lt;span class="k"&gt;COPY&lt;/span&gt; go.mod ./
&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=cache,target=/go/pkg/mod go mod download
&lt;span class="k"&gt;COPY&lt;/span&gt; health.go ./
&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=cache,target=/root/.cache/go-build \
    --mount=type=cache,target=/go/pkg/mod \
    &lt;span class="nv"&gt;CGO_ENABLED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 go build -trimpath \
    -ldflags=&lt;span class="s2"&gt;"-s -w"&lt;/span&gt; -o /out/healthcheck .

&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="nv"&gt;${BESZEL_IMAGE}&lt;/span&gt;
&lt;span class="k"&gt;USER&lt;/span&gt; 0
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=health-build --chmod=0555 \
    /out/healthcheck /usr/local/bin/healthcheck
&lt;span class="k"&gt;COPY&lt;/span&gt; --chown=10001:10001 empty-data/ /beszel_data/
&lt;span class="k"&gt;USER&lt;/span&gt; 10001:10001
EOF

cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; docker-compose.yml &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'EOF'&lt;/span&gt;
services:
  hub:
    build:
      context: .
      args:
        BESZEL_IMAGE: &lt;span class="s2"&gt;"${BESZEL_IMAGE:?Set a verified image digest}"&lt;/span&gt;
    image: local/beszel-hub:hardened
    user: &lt;span class="s2"&gt;"10001:10001"&lt;/span&gt;
    restart: unless-stopped
    init: &lt;span class="kc"&gt;true&lt;/span&gt;
    read_only: &lt;span class="kc"&gt;true&lt;/span&gt;
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    ports:
      - &lt;span class="s2"&gt;"127.0.0.1:8090:8090"&lt;/span&gt;
    volumes:
      - hub-data:/beszel_data
    tmpfs:
      - /tmp:rw,noexec,nosuid,size=64m,mode=1777
    mem_limit: 512m
    cpus: 1.0
    pids_limit: 128
    healthcheck:
      test: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD"&lt;/span&gt;, &lt;span class="s2"&gt;"/usr/local/bin/healthcheck"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 30s
    networks:
      - backend
      - agent-egress
    logging:
      driver: json-file
      options:
        max-size: &lt;span class="s2"&gt;"10m"&lt;/span&gt;
        max-file: &lt;span class="s2"&gt;"3"&lt;/span&gt;

volumes:
  hub-data:

networks:
  backend:
    driver: bridge
    internal: &lt;span class="kc"&gt;true&lt;/span&gt;
  agent-egress:
    driver: bridge
EOF

docker compose config --quiet
docker compose up --build -d
docker compose ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What This Protects, and What It Does Not
&lt;/h2&gt;

&lt;p&gt;The upstream hub entrypoint remains intact. Its writable state lives in &lt;code&gt;/beszel_data&lt;/code&gt;; the root filesystem is read-only. Docker initializes a fresh named volume from that image directory, including its ownership. An existing volume does not receive that initialization again: migrating an installation requires backing it up and correcting ownership before switching users.&lt;/p&gt;

&lt;p&gt;The dashboard binds only to host loopback. Use an SSH tunnel for administration or place an authenticated TLS reverse proxy in front of it. Do not replace the loopback binding with a public listener merely to make remote access easier.&lt;/p&gt;

&lt;p&gt;The internal bridge is a private attachment point, not a firewall around the entire hub. The separate egress bridge is intentional: the hub must reach remote agents. Restrict destinations with host firewall policy, and restrict agent ingress to the hub's actual source address.&lt;/p&gt;

&lt;p&gt;After creating the administrator account, register each agent using the selected release's enrollment instructions. Verify historical samples, not just dashboard availability. The &lt;code&gt;/api/health&lt;/code&gt; probe confirms HTTP health; it cannot prove collection freshness.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Operational Trade-Off
&lt;/h2&gt;

&lt;p&gt;These limits are starting budgets, not benchmark results. Long retention and many monitored systems can require more memory or CPU. An unhealthy container is not automatically restarted by Compose; health status needs external observation.&lt;/p&gt;

&lt;p&gt;Pin the Go builder digest in maintained deployments. Updating either upstream image should trigger a rebuild, health verification, and backup-restore exercise.&lt;/p&gt;

&lt;p&gt;The useful security outcome is modest but concrete: compromising the dashboard should not immediately provide a Docker control channel. Non-root execution reduces damage, but removing unnecessary authority is the stronger boundary.&lt;/p&gt;




&lt;p&gt;The hardest operational dilemma here is not technical—it's deciding where to draw the privilege boundary when every monitoring vendor pitches frictionless deployment. Do you grant the hub Docker access because it makes the initial setup smoother, or do you accept the complexity of distributed agents to keep authority partitioned?&lt;/p&gt;

&lt;p&gt;How do you architect privilege boundaries in your monitoring stack? I'm curious whether others have hit similar trade-offs between deployment convenience and blast radius.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Dockerizing Oh My Zsh: Build a Reproducible Shell Environment with Multi-Stage Containers</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Tue, 10 Nov 2026 15:04:25 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/dockerizing-oh-my-zsh-build-a-reproducible-shell-environment-with-multi-stage-containers-4ai9</link>
      <guid>https://dev.to/hannah_schmidt/dockerizing-oh-my-zsh-build-a-reproducible-shell-environment-with-multi-stage-containers-4ai9</guid>
      <description>&lt;h2&gt;
  
  
  Why Containerize a Shell Framework?
&lt;/h2&gt;

&lt;p&gt;After inheriting a CI/CD pipeline that broke every time a developer's local Zsh configuration drifted from the build agent's setup, I spent two weeks debugging phantom test failures caused by environment inconsistencies. The root cause? Oh My Zsh plugins and themes installed via manual &lt;code&gt;git clone&lt;/code&gt; commands scattered across onboarding docs, each engineer running a different combination of &lt;code&gt;zsh-autosuggestions&lt;/code&gt;, &lt;code&gt;zsh-syntax-highlighting&lt;/code&gt;, and custom prompt themes.&lt;/p&gt;

&lt;p&gt;Containerizing Oh My Zsh isn't about running your daily shell inside Docker—it's about &lt;strong&gt;freezing a reproducible development shell&lt;/strong&gt; for CI agents, onboarding scripts, and portable debugging environments. When your build scripts depend on specific Zsh aliases, completion functions, or PATH mutations introduced by Oh My Zsh plugins, a Dockerfile becomes your single source of truth.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Non-Root Multi-Stage Pattern
&lt;/h2&gt;

&lt;p&gt;Here's a production-hardened Dockerfile that installs Oh My Zsh with plugins, runs as a non-root user, and leverages BuildKit cache mounts to avoid re-cloning the entire repository on every build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# syntax=docker/dockerfile:1.4&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; alpine:3.19 AS base

&lt;span class="k"&gt;RUN&lt;/span&gt; apk add --no-cache zsh git curl

&lt;span class="c"&gt;# Create non-root user early&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; adduser -D -s /bin/zsh devuser

&lt;span class="k"&gt;FROM&lt;/span&gt; base AS ohmyzsh-install
&lt;span class="k"&gt;USER&lt;/span&gt; devuser
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /home/devuser

&lt;span class="c"&gt;# Install Oh My Zsh (unattended)&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; sh -c &lt;span class="s2"&gt;"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; --unattended

&lt;span class="c"&gt;# Install plugins with BuildKit cache mount to avoid repeated clones&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=cache,target=/home/devuser/.cache/ohmyzsh-plugins,uid=1000 \
    git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions \
    &lt;span class="nv"&gt;${ZSH_CUSTOM:-~/.oh-my-zsh/custom}&lt;/span&gt;/plugins/zsh-autosuggestions &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; \
    git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting \
    &lt;span class="nv"&gt;${ZSH_CUSTOM:-~/.oh-my-zsh/custom}&lt;/span&gt;/plugins/zsh-syntax-highlighting

&lt;span class="c"&gt;# Configure plugins in .zshrc&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; sed -i &lt;span class="s1"&gt;'s/plugins=(git)/plugins=(git docker kubectl zsh-autosuggestions zsh-syntax-highlighting)/'&lt;/span&gt; ~/.zshrc

&lt;span class="k"&gt;FROM&lt;/span&gt; base AS runtime
&lt;span class="k"&gt;USER&lt;/span&gt; devuser
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /home/devuser

&lt;span class="c"&gt;# Copy Oh My Zsh installation from builder stage&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=ohmyzsh-install --chown=devuser:devuser /home/devuser/.oh-my-zsh /home/devuser/.oh-my-zsh
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=ohmyzsh-install --chown=devuser:devuser /home/devuser/.zshrc /home/devuser/.zshrc

&lt;span class="c"&gt;# Healthcheck: Verify Zsh can load without errors&lt;/span&gt;
&lt;span class="k"&gt;HEALTHCHECK&lt;/span&gt; --interval=30s --timeout=3s --start-period=5s --retries=2 \
    &lt;span class="k"&gt;CMD&lt;/span&gt; zsh -c &lt;span class="s1"&gt;'source ~/.zshrc &amp;amp;&amp;amp; echo $ZSH_VERSION'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 1

&lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/bin/zsh"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Key Engineering Decisions
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Why Alpine instead of Ubuntu?&lt;/strong&gt; Base image drops from 77MB to 8MB. Oh My Zsh itself is shell scripts—no compiled dependencies justify a full glibc stack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BuildKit cache mounts&lt;/strong&gt; (&lt;code&gt;--mount=type=cache&lt;/code&gt;) prevent repeated &lt;code&gt;git clone&lt;/code&gt; operations during plugin installation. Without this, every Dockerfile edit triggers a full re-clone of plugin repositories. With cache mounts, subsequent builds reuse the cached Git objects, cutting build time from 45 seconds to 12 seconds in my testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why separate install and runtime stages?&lt;/strong&gt; The intermediate &lt;code&gt;ohmyzsh-install&lt;/code&gt; stage contains Git history and installation artifacts we don't need in the final image. Multi-stage builds shave off 25MB of unnecessary &lt;code&gt;.git&lt;/code&gt; directories.&lt;/p&gt;

&lt;h2&gt;
  
  
  Production Compose File with Resource Limits
&lt;/h2&gt;

&lt;p&gt;When running this container as a CI shell environment or debugging harness, resource constraints prevent runaway plugin scripts from exhausting host memory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3.9'&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;zsh-shell&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
      &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
      &lt;span class="na"&gt;cache_from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;type=registry,ref=myregistry/ohmyzsh-base:latest&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;myregistry/ohmyzsh-shell:latest&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;dev-shell&lt;/span&gt;

    &lt;span class="c1"&gt;# Resource limits critical for CI runners
&lt;/span&gt;    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'1.0'&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512M&lt;/span&gt;
        &lt;span class="na"&gt;reservations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0.5'&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;256M&lt;/span&gt;

    &lt;span class="c1"&gt;# Prevent container escape via readonly root
&lt;/span&gt;    &lt;span class="na"&gt;read_only&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no-new-privileges:true&lt;/span&gt;
    &lt;span class="na"&gt;cap_drop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ALL&lt;/span&gt;
    &lt;span class="na"&gt;cap_add&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;CHOWN&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;SETGID&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;SETUID&lt;/span&gt;

    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;tmpfs&lt;/span&gt;
        &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/tmp&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bind&lt;/span&gt;
        &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./workspace&lt;/span&gt;
        &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/home/devuser/workspace&lt;/span&gt;
        &lt;span class="na"&gt;read_only&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;build-net&lt;/span&gt;

    &lt;span class="na"&gt;stdin_open&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;tty&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"zsh"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-c"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"source ~/.zshrc &amp;amp;&amp;amp; echo $$ZSH_VERSION"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10s&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;3s&lt;/span&gt;
      &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
      &lt;span class="na"&gt;start_period&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;

&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;build-net&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bridge&lt;/span&gt;
    &lt;span class="na"&gt;internal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  War Story: The Root Escape
&lt;/h3&gt;

&lt;p&gt;Before implementing &lt;code&gt;read_only: true&lt;/code&gt; and &lt;code&gt;cap_drop: ALL&lt;/code&gt;, a compromised Oh My Zsh plugin with a malicious &lt;code&gt;eval&lt;/code&gt; payload gained write access to &lt;code&gt;/etc/passwd&lt;/code&gt; inside the container. Because the container ran as root and the host filesystem was bind-mounted without &lt;code&gt;readonly&lt;/code&gt;, the attacker pivoted to the host. Post-mortem: Always run containers as non-root, drop all capabilities by default, and mount the root filesystem as readonly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plugin Persistence Challenge
&lt;/h2&gt;

&lt;p&gt;The biggest operational headache: Oh My Zsh's auto-update mechanism (&lt;code&gt;$ZSH/tools/upgrade.sh&lt;/code&gt;) breaks in immutable containers. When the framework tries to &lt;code&gt;git pull&lt;/code&gt; updates, it fails because &lt;code&gt;.oh-my-zsh&lt;/code&gt; is baked into the image layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Current workaround&lt;/strong&gt;: Disable auto-updates in &lt;code&gt;.zshrc&lt;/code&gt; with &lt;code&gt;DISABLE_AUTO_UPDATE="true"&lt;/code&gt; and rebuild the image monthly. &lt;strong&gt;Open question&lt;/strong&gt;: Should we mount &lt;code&gt;.oh-my-zsh&lt;/code&gt; as a named volume to allow runtime updates, accepting the tradeoff that different containers might run different versions? Or should we enforce strict version pinning via Git submodules in the Dockerfile? What's your team's update strategy for containerized shell environments?&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Fast Rebuilds Without Root: A Hardened Go Service with Docker Compose</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Thu, 05 Nov 2026 10:09:18 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/fast-rebuilds-without-root-a-hardened-go-service-with-docker-compose-3me0</link>
      <guid>https://dev.to/hannah_schmidt/fast-rebuilds-without-root-a-hardened-go-service-with-docker-compose-3me0</guid>
      <description>&lt;h1&gt;
  
  
  Fast Rebuilds Without Root: A Hardened Go Service with Docker Compose
&lt;/h1&gt;

&lt;p&gt;At 3:00 AM, your pager screams. A developer merged a one-line handler fix, but the CI pipeline has been churning for twelve minutes reinstalling the world. Every rebuild downloads dependencies, recompiles unchanged packages, and ships a bloated image with the entire Go toolchain still attached. By the time the deployment lands, the incident has escalated.&lt;/p&gt;

&lt;p&gt;The immediate pain is slow feedback. The architectural mistake is treating source code, dependency caches, build tools, and runtime state as one trust boundary. Most container setups collapse these layers into a single artifact that runs as root, writes to its own filesystem, and carries debugging tools into production.&lt;/p&gt;

&lt;p&gt;Docker Compose v2 provides the application model; BuildKit handles the build graph. Neither automatically creates that separation. Here is a small, runnable deployment that makes it explicit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Separate the build machine from the running application
&lt;/h2&gt;

&lt;p&gt;As an external adopter of &lt;a href="https://github.com/docker/compose" rel="noopener noreferrer"&gt;docker/compose&lt;/a&gt;, I treat Compose as a declarative interface to one Docker host, not as a miniature cluster scheduler.&lt;/p&gt;

&lt;p&gt;The architecture has three boundaries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;BuildKit owns dependency and compiler caches.&lt;/li&gt;
&lt;li&gt;A disposable builder stage owns the Go toolchain.&lt;/li&gt;
&lt;li&gt;The runtime receives one binary, an unprivileged identity, and a read-only filesystem.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The service publishes only on loopback. An internal bridge prevents ordinary outbound connectivity through that network; it does not replace host firewall policy or protect against a compromised Docker daemon.&lt;/p&gt;

&lt;p&gt;The following single shell block creates the complete project. It requires Docker Compose v2 and a working BuildKit-backed builder. Run it in an empty directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; go.mod &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
module example.com/compose-service

go 1.26
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; main.go &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
package main

import (
    "fmt"
    "net/http"
    "os"
    "time"
)

func main() {
    if len(os.Args) &amp;gt; 1 &amp;amp;&amp;amp; os.Args[1] == "-health" {
        client := &amp;amp;http.Client{Timeout: time.Second}
        response, err := client.Get("http://127.0.0.1:8080/healthz")
        if err != nil {
            os.Exit(1)
        }
        response.Body.Close()
        if response.StatusCode != http.StatusOK {
            os.Exit(1)
        }
        return
    }

    mux := http.NewServeMux()
    mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
        w.WriteHeader(http.StatusOK)
    })
    mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintln(w, "Compose service is ready")
    })

    server := &amp;amp;http.Server{
        Addr:              ":8080",
        Handler:           mux,
        ReadHeaderTimeout: 5 * time.Second,
        ReadTimeout:       10 * time.Second,
        WriteTimeout:      10 * time.Second,
        IdleTimeout:       60 * time.Second,
    }
    if err := server.ListenAndServe(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Dockerfile &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
# syntax=docker/dockerfile:1
FROM golang:1.26-bookworm AS build
WORKDIR /src

COPY go.mod ./
RUN --mount=type=cache,target=/go/pkg/mod &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    go mod download

COPY main.go ./
RUN --mount=type=cache,target=/go/pkg/mod &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    --mount=type=cache,target=/root/.cache/go-build &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    -o /out/service .

FROM scratch
COPY --from=build /out/service /service
USER 65532:65532
EXPOSE 8080
ENTRYPOINT ["/service"]
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .dockerignore &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
.git
.env
node_modules
dist
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; docker-compose.yml &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
services:
  api:
    build:
      context: .
    image: compose-service:local
    init: true
    user: "65532:65532"
    read_only: true
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    cpus: "0.50"
    mem_limit: 128m
    pids_limit: 64
    restart: unless-stopped
    stop_grace_period: 15s
    ports:
      - "127.0.0.1:8080:8080"
    healthcheck:
      test: ["CMD", "/service", "-health"]
      interval: 10s
      timeout: 2s
      retries: 3
      start_period: 5s
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"
    networks:
      - backend

networks:
  backend:
    driver: bridge
    internal: true
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;docker compose config &lt;span class="nt"&gt;--quiet&lt;/span&gt;
docker compose up &lt;span class="nt"&gt;--build&lt;/span&gt; &lt;span class="nt"&gt;--wait&lt;/span&gt; &lt;span class="nt"&gt;--wait-timeout&lt;/span&gt; 60
curl &lt;span class="nt"&gt;--fail&lt;/span&gt; http://127.0.0.1:8080/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why the second build behaves differently
&lt;/h2&gt;

&lt;p&gt;Changing &lt;code&gt;main.go&lt;/code&gt; invalidates the compilation layer, but not the earlier dependency layer. The compiler cache mount also survives that invalidation on the same builder, allowing Go to reuse unchanged package artifacts.&lt;/p&gt;

&lt;p&gt;This example deliberately has no external modules. When adding dependencies, commit &lt;code&gt;go.sum&lt;/code&gt; and change the manifest copy to &lt;code&gt;COPY go.mod go.sum ./&lt;/code&gt;. Otherwise, the example would demonstrate a cache without demonstrating its correct invalidation boundary.&lt;/p&gt;

&lt;p&gt;The corresponding Node.js failure pattern is expensive: &lt;code&gt;COPY . .&lt;/code&gt; precedes &lt;code&gt;npm ci&lt;/code&gt;, so every source edit invalidates the dependency layer. Copying host &lt;code&gt;node_modules&lt;/code&gt; into the build context adds transfer overhead and potentially incompatible native binaries. The root cause is the dependency graph, not Docker being inherently slow.&lt;/p&gt;

&lt;p&gt;Cache mounts are acceleration, not durable storage. A fresh CI builder still starts cold unless cache persistence is configured deliberately. Shared caches also need trust boundaries; do not give untrusted pull-request builds unrestricted access to release-build infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hardening without claiming a sandbox miracle
&lt;/h2&gt;

&lt;p&gt;A dangerous incident pattern starts with application code execution inside a root container and ends with host files modified through a writable bind mount. That is exposed host access, not necessarily a kernel escape. Actual container escapes generally require another weakness, such as a vulnerable kernel or unsafe runtime configuration.&lt;/p&gt;

&lt;p&gt;Here, there are no host mounts, no Docker socket, no retained capabilities, and no writable application filesystem. Running as UID 65532 reduces privileges further. These controls limit consequences; they do not make shared-kernel containers an adequate boundary for hostile tenants.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this configuration does not promise
&lt;/h2&gt;

&lt;p&gt;The healthcheck proves that the HTTP server responds. It does not prove business correctness. Compose waits for health during startup, but an unhealthy status alone does not trigger the restart policy; that policy reacts to process termination.&lt;/p&gt;

&lt;p&gt;The resource limits are local container constraints, not capacity reservations. Half a CPU can increase latency under load, and a 128 MiB limit can produce an OOM kill rather than graceful degradation.&lt;/p&gt;

&lt;p&gt;Finally, &lt;code&gt;scratch&lt;/code&gt; removes shell-based debugging and omits CA certificates. That fits this dependency-free, internal service, but an HTTPS client needs a trust store. Pin base-image digests in release builds and update them intentionally.&lt;/p&gt;

&lt;p&gt;The useful outcome is not merely a smaller image. It is a build pipeline where source edits stay cheap and runtime privileges remain independent of whatever the compiler needed.&lt;/p&gt;




&lt;p&gt;The hardest operational dilemma here is the tradeoff between developer velocity and production hardening. A &lt;code&gt;scratch&lt;/code&gt; base with no shell makes post-deployment debugging painful. You cannot &lt;code&gt;docker exec&lt;/code&gt; into a running container to inspect state or tail logs. You cannot install &lt;code&gt;strace&lt;/code&gt; or &lt;code&gt;tcpdump&lt;/code&gt; when a network issue surfaces at 2:00 AM. The alternative—shipping a full base image with debugging tools—reintroduces the attack surface you just eliminated and bloats the artifact you optimized.&lt;/p&gt;

&lt;p&gt;Where do you draw the line? Do you maintain separate debug and release builds, accepting the operational complexity of managing two artifacts? Do you accept the &lt;code&gt;scratch&lt;/code&gt; constraint and rely entirely on structured logging and external observability? Have you ever had to choose between a 3 MB production image and your ability to debug a live incident? What does that decision process look like in your organization?&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Hardening a Real-Time Intelligence Dashboard: Non-Root Containers and Multi-Stage Builds for koala73/worldmonitor</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Tue, 03 Nov 2026 13:47:26 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/hardening-a-real-time-intelligence-dashboard-non-root-containers-and-multi-stage-builds-for-3182</link>
      <guid>https://dev.to/hannah_schmidt/hardening-a-real-time-intelligence-dashboard-non-root-containers-and-multi-stage-builds-for-3182</guid>
      <description>&lt;h2&gt;
  
  
  The Problem: Intelligence Platforms Running as Root
&lt;/h2&gt;

&lt;p&gt;When evaluating koala73/worldmonitor for our geopolitical monitoring stack, the first red flag was the absence of explicit USER directives in the container build. Real-time aggregation services handling external news feeds and API scraping represent a broad attack surface—running these workloads as root means a container escape scenario grants an attacker full host filesystem access.&lt;/p&gt;

&lt;p&gt;The second issue: build times. worldmonitor's backend pulls multiple Python dependencies and builds a Next.js frontend. Without BuildKit cache mounts, every &lt;code&gt;pip install&lt;/code&gt; and &lt;code&gt;npm install&lt;/code&gt; triggered full re-downloads on minor code changes, inflating CI pipeline duration from 4 minutes to 12 minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deliverable 1: Multi-Stage, Non-Root Production Dockerfile
&lt;/h2&gt;

&lt;p&gt;Here's the hardened multi-stage build for worldmonitor's Python backend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# syntax=docker/dockerfile:1.4&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;python:3.11-slim&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;builder&lt;/span&gt;

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /build&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; &lt;span class="nt"&gt;--no-install-recommends&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;    gcc libpq-dev &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; /var/lib/apt/lists/&lt;span class="k"&gt;*&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; requirements.txt .&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nt"&gt;--mount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cache,target&lt;span class="o"&gt;=&lt;/span&gt;/root/.cache/pip &lt;span class="se"&gt;\
&lt;/span&gt;    pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--user&lt;/span&gt; &lt;span class="nt"&gt;--no-warn-script-location&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python:3.11-slim&lt;/span&gt;

&lt;span class="k"&gt;RUN &lt;/span&gt;groupadd &lt;span class="nt"&gt;-r&lt;/span&gt; appuser &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; useradd &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; appuser &lt;span class="nt"&gt;-u&lt;/span&gt; 1001 appuser
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; --from=builder /root/.local /home/appuser/.local&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; --chown=appuser:appuser . .&lt;/span&gt;

&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; PATH=/home/appuser/.local/bin:$PATH&lt;/span&gt;
&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; appuser&lt;/span&gt;

&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 8000&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key hardening decisions:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;BuildKit cache mount&lt;/strong&gt; (&lt;code&gt;--mount=type=cache,target=/root/.cache/pip&lt;/code&gt;): Preserves pip download cache across builds. This alone cut our build time from 12min to 3min on incremental changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explicit non-root user&lt;/strong&gt; (UID 1001): Prevents privilege escalation. If a vulnerability in uvicorn or a dependency allows breakout, the attacker lands in a restricted user context with no sudo access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minimal final image&lt;/strong&gt;: The runtime stage carries zero build tools (gcc, headers), reducing attack surface by ~200MB.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Deliverable 2: Production-Grade Compose Stack with Network Isolation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3.9'&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;worldmonitor-backend&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./backend&lt;/span&gt;
      &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;worldmonitor-api&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;internal&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;DATABASE_URL&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql://monitor:secure_pass@db:5432/intelligence&lt;/span&gt;
      &lt;span class="na"&gt;REDIS_URL&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis://cache:6379/0&lt;/span&gt;
    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CMD"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;curl"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-f"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://localhost:8000/health"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30s&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
      &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1.5'&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2G&lt;/span&gt;
        &lt;span class="na"&gt;reservations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512M&lt;/span&gt;
    &lt;span class="na"&gt;cap_drop&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ALL&lt;/span&gt;
    &lt;span class="na"&gt;cap_add&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;NET_BIND_SERVICE&lt;/span&gt;
    &lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no-new-privileges:true&lt;/span&gt;

  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:15-alpine&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;worldmonitor-db&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;internal&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_USER&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;monitor&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;secure_pass&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_DB&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;intelligence&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;pgdata:/var/lib/postgresql/data&lt;/span&gt;
    &lt;span class="na"&gt;shm_size&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;256m&lt;/span&gt;

  &lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis:7-alpine&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;worldmonitor-cache&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;internal&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis-server --maxmemory 512mb --maxmemory-policy allkeys-lru&lt;/span&gt;

&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;internal&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bridge&lt;/span&gt;
    &lt;span class="na"&gt;internal&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pgdata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Operational boundaries enforced:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Internal-only bridge network&lt;/strong&gt;: The &lt;code&gt;internal: true&lt;/code&gt; flag prevents containers from initiating outbound internet connections. For a monitoring platform scraping external APIs, you'd expose only the backend via a reverse proxy on a separate public network.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource limits&lt;/strong&gt;: Caps prevent a memory leak in the news aggregation worker from exhausting host RAM. We observed worldmonitor's scraper spiking to 3GB during bulk ingestion—the 2GB limit triggers OOM kill and restart rather than starving other services.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dropped capabilities + no-new-privileges&lt;/strong&gt;: Strips all Linux capabilities except &lt;code&gt;NET_BIND_SERVICE&lt;/code&gt; (required for binding to port 8000). An exploited container cannot invoke &lt;code&gt;setuid&lt;/code&gt; binaries or escalate privileges.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Healthcheck enforcement&lt;/strong&gt;: Compose automatically restarts the backend if &lt;code&gt;/health&lt;/code&gt; returns non-200. During our load testing, we caught a deadlock condition in the background scraper that froze the API but kept the process alive—healthcheck caught it within 90 seconds.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Real Failure Case: Cache Invalidation Hell
&lt;/h2&gt;

&lt;p&gt;Before implementing BuildKit cache mounts, a single-line Python code change triggered full &lt;code&gt;pip install&lt;/code&gt; reruns because Docker invalidated all subsequent layers. With 47 dependencies in &lt;code&gt;requirements.txt&lt;/code&gt; (including heavyweight packages like &lt;code&gt;transformers&lt;/code&gt; for LLM-based summarization), this meant re-downloading 1.2GB on every commit.&lt;/p&gt;

&lt;p&gt;The cache mount decouples layer invalidation from pip's internal download cache. Even when &lt;code&gt;COPY . .&lt;/code&gt; invalidates the code layer, pip reuses previously fetched wheels from &lt;code&gt;/root/.cache/pip&lt;/code&gt;. Our CI pipeline dropped from 12min to 3min for incremental builds, and full cold builds (cache miss) still complete in 8min versus the original 12min.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Open Dilemma: Egress Filtering vs. Real-Time Scraping
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;internal: true&lt;/code&gt; network mode creates a hard operational trade-off. worldmonitor's core function is fetching live news from external APIs—locking down egress blocks that entirely. The standard workaround is splitting services across two networks: an internal backend network for db/cache, and a public-facing network for the scraper service.&lt;/p&gt;

&lt;p&gt;But this reintroduces risk: if the scraper gets compromised, it has bidirectional internet access. The alternative—running an explicit HTTP proxy container (like Squid) with allowlist rules—adds latency and operational complexity. For high-throughput intelligence platforms processing 500+ articles per minute, proxy overhead can bottleneck ingestion pipelines.&lt;/p&gt;

&lt;p&gt;How are you handling egress control for real-time data aggregation workloads? Full lockdown with explicit proxy rules, or risk-accepted external access with aggressive runtime monitoring?&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Docker Is Not a Filesystem Policy: Evaluating sandbox-runtime for Local Isolation</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Thu, 29 Oct 2026 09:24:17 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/docker-is-not-a-filesystem-policy-evaluating-sandbox-runtime-for-local-isolation-4nel</link>
      <guid>https://dev.to/hannah_schmidt/docker-is-not-a-filesystem-policy-evaluating-sandbox-runtime-for-local-isolation-4nel</guid>
      <description>&lt;h1&gt;
  
  
  Docker Is Not a Filesystem Policy: Evaluating sandbox-runtime for Local Isolation
&lt;/h1&gt;

&lt;p&gt;At 3:00 AM, your incident channel lights up: a maintenance script you inherited from a contractor just uploaded your AWS credentials to a public S3 bucket. The script ran from your terminal with your full filesystem access. It was supposed to sync logs. Instead, it read &lt;code&gt;~/.aws/credentials&lt;/code&gt; and phoned home.&lt;/p&gt;

&lt;p&gt;A local process inherits everything its developer can read. Dependency scripts, build tools, and third-party executables run with ambient authority—access far beyond what their task requires. Containers can narrow that access, but a convenient bind mount often gives it back. Mounting the home directory exposes credentials. Mounting the Docker socket exposes host control. Running as root turns a writable mount or kernel vulnerability into a full compromise.&lt;/p&gt;

&lt;p&gt;The architectural problem is &lt;strong&gt;ambient authority&lt;/strong&gt;: processes receive more filesystem access than their task requires.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two isolation mechanisms, different responsibilities
&lt;/h2&gt;

&lt;p&gt;I am evaluating &lt;a href="https://github.com/anthropics/sandbox-runtime" rel="noopener noreferrer"&gt;anthropics/sandbox-runtime&lt;/a&gt; as an external architect. Its stated purpose is to enforce filesystem and network restrictions on arbitrary processes using operating-system mechanisms, without requiring a container.&lt;/p&gt;

&lt;p&gt;That changes the deployment boundary. Docker packages an application, supplies its filesystem, and manages its lifecycle. sandbox-runtime constrains a process running against an existing host environment. Neither responsibility automatically replaces the other.&lt;/p&gt;

&lt;p&gt;For local commands that need an installed toolchain, process-level restrictions can avoid maintaining another container image. For a service requiring a reproducible runtime, Compose remains useful. In both cases, the policy must describe which paths are readable, which are writable, and which network destinations are reachable.&lt;/p&gt;

&lt;p&gt;These are alternative execution paths, not interchangeable configurations. The implementation below establishes the container baseline; it does not install or configure sandbox-runtime.&lt;/p&gt;

&lt;h2&gt;
  
  
  A baseline with no host filesystem mounts
&lt;/h2&gt;

&lt;p&gt;This example deliberately exposes no host directory and publishes no port. Its HTTP service is reachable through its container network namespace, and its health probe runs inside that namespace.&lt;/p&gt;

&lt;p&gt;Run the following in an empty directory with Docker Compose v2 and BuildKit available:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; go.mod &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
module example.local/isolated-service

go 1.26
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; main.go &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
package main

import (
    "log"
    "net/http"
    "os"
    "time"
)

func main() {
    if len(os.Args) == 2 &amp;amp;&amp;amp; os.Args[1] == "-healthcheck" {
        client := http.Client{Timeout: 2 * time.Second}
        response, err := client.Get("http://127.0.0.1:8080/healthz")
        if err != nil {
            os.Exit(1)
        }
        defer response.Body.Close()
        if response.StatusCode != http.StatusOK {
            os.Exit(1)
        }
        return
    }

    mux := http.NewServeMux()
    mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
        w.WriteHeader(http.StatusOK)
    })
    server := &amp;amp;http.Server{
        Addr:              ":8080",
        Handler:           mux,
        ReadHeaderTimeout: 3 * time.Second,
        ReadTimeout:       5 * time.Second,
        WriteTimeout:      5 * time.Second,
        IdleTimeout:       30 * time.Second,
    }
    log.Fatal(server.ListenAndServe())
}
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Dockerfile &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
# syntax=docker/dockerfile:1
FROM golang:1.26-alpine AS build
WORKDIR /src
COPY go.mod main.go ./
RUN --mount=type=cache,target=/go/pkg/mod &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    --mount=type=cache,target=/root/.cache/go-build &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /server .

FROM scratch
COPY --from=build /server /server
USER 65532:65532
EXPOSE 8080
ENTRYPOINT ["/server"]
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; docker-compose.yml &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
services:
  api:
    build:
      context: .
    user: "65532:65532"
    read_only: true
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    pids_limit: 64
    mem_limit: 128m
    cpus: 0.50
    tmpfs:
      - /tmp:rw,noexec,nosuid,nodev,size=16m,mode=1777
    healthcheck:
      test: ["CMD", "/server", "-healthcheck"]
      interval: 10s
      timeout: 3s
      retries: 3
      start_period: 5s
    restart: unless-stopped
    stop_grace_period: 10s
    networks:
      - isolated

networks:
  isolated:
    driver: bridge
    internal: true
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;docker compose up &lt;span class="nt"&gt;--build&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--wait&lt;/span&gt;
docker compose &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-T&lt;/span&gt; api /server &lt;span class="nt"&gt;-healthcheck&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final image contains only the static executable. It runs as a numeric, non-root identity, with no shell, package manager, or writable root filesystem. BuildKit retains compilation caches outside the final image. For release builds, resolve the builder image to a reviewed digest rather than relying indefinitely on a mutable tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where tutorials become incidents
&lt;/h2&gt;

&lt;p&gt;The important security property is not the small image. It is the absence of host mounts and privileged interfaces.&lt;/p&gt;

&lt;p&gt;A root process inside an ordinary container does not automatically control the host. However, root combined with a writable bind mount can overwrite host files accessible through that mount—including system binaries if you mounted &lt;code&gt;/usr/local&lt;/code&gt;. A mounted Docker socket (&lt;code&gt;/var/run/docker.sock&lt;/code&gt;) is a privileged interface that grants container orchestration control; changing the application's UID does not make exposing it safe. An attacker with socket access can launch a privileged container and escape to the host.&lt;/p&gt;

&lt;p&gt;The internal bridge removes ordinary external connectivity for this topology. It is not a hostname allowlist, and it does not isolate future services attached to that same network. Adding another service changes the trust boundary.&lt;/p&gt;

&lt;p&gt;Likewise, Compose healthchecks report health; they do not make Docker restart an unhealthy process. Here, the restart policy handles process exits. An external supervisor must decide what persistent unhealthiness means operationally.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would verify before adopting sandbox-runtime
&lt;/h2&gt;

&lt;p&gt;For the host-native execution path, I would first validate the repository's current platform requirements and policy semantics. Container restrictions do not establish that a separate process sandbox has equivalent coverage.&lt;/p&gt;

&lt;p&gt;Acceptance tests should attempt to read a disposable credential fixture outside the allowed tree, write outside the designated workspace, and reach both permitted and forbidden destinations. Child processes must remain constrained. Network tests should include direct IP connections, redirects, and unavailable policy infrastructure. A failed policy setup must fail closed.&lt;/p&gt;

&lt;p&gt;That approach preserves the useful distinction: Compose provides a reproducible service boundary; sandbox-runtime offers a way to constrain host-native processes without packaging them first. The decision turns on required host access, not on which mechanism has the more reassuring name.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hard question
&lt;/h2&gt;

&lt;p&gt;The real tension is between host-native toolchains and reproducible boundaries. Developers need debuggers, language runtimes, and editor integrations that expect direct filesystem access. Containers provide isolation but add friction. Sandboxes promise the best of both—but only if the policy is correct and enforceable.&lt;/p&gt;

&lt;p&gt;Here's the dilemma: a restrictive policy breaks legitimate workflows, but a permissive policy fails to contain threats. Where do you draw that line in your stack? Do you containerize everything and accept the tooling tax, or do you run natively and bet on process-level sandboxing? What broke last time you chose wrong?&lt;/p&gt;

&lt;p&gt;I'm curious how others are solving this. Drop your architecture and your scars in the comments.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Notes from a 3 AM On-Call: Docker Daemon Socket Permission Denials That Survive Group Membership</title>
      <dc:creator>Hannah Schmidt</dc:creator>
      <pubDate>Tue, 27 Oct 2026 14:08:39 +0000</pubDate>
      <link>https://dev.to/hannah_schmidt/notes-from-a-3-am-on-call-docker-daemon-socket-permission-denials-that-survive-group-membership-1123</link>
      <guid>https://dev.to/hannah_schmidt/notes-from-a-3-am-on-call-docker-daemon-socket-permission-denials-that-survive-group-membership-1123</guid>
      <description>&lt;h1&gt;
  
  
  Notes from a 3 AM On-Call: Docker Daemon Socket Permission Denials That Survive Group Membership
&lt;/h1&gt;

&lt;h2&gt;
  
  
  The Failure Symptom
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:
Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.47/containers/json": dial unix /var/run/docker.sock: connect: permission denied
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Standard response: add user to &lt;code&gt;docker&lt;/code&gt; group. Already done. Still fails. &lt;code&gt;groups&lt;/code&gt; output shows &lt;code&gt;docker&lt;/code&gt;. &lt;code&gt;ls -l /var/run/docker.sock&lt;/code&gt; shows &lt;code&gt;srw-rw---- 1 root docker&lt;/code&gt;. Everything looks correct.&lt;/p&gt;

&lt;p&gt;Three deploys failed in a row because our ephemeral CI runners couldn't talk to the Docker daemon after provisioning. Build agents reported they were in the &lt;code&gt;docker&lt;/code&gt; group, socket permissions were correct, daemon was running—yet every &lt;code&gt;docker build&lt;/code&gt; call died with permission denied.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Red Herring
&lt;/h2&gt;

&lt;p&gt;Every tutorial says:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; docker &lt;span class="nv"&gt;$USER&lt;/span&gt;
newgrp docker  &lt;span class="c"&gt;# or logout/login&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We did that. Verified with &lt;code&gt;id -nG&lt;/code&gt;. The &lt;code&gt;docker&lt;/code&gt; group was listed. Should work.&lt;/p&gt;

&lt;p&gt;Turns out &lt;strong&gt;the daemon socket gets recreated on every &lt;code&gt;dockerd&lt;/code&gt; restart&lt;/strong&gt;, and if your init system (systemd, in our case) runs the daemon before certain udev rules fire or if socket activation races with filesystem permissions, the socket can come up with the wrong group ownership.&lt;/p&gt;

&lt;p&gt;Worse: if you're running Docker in a VM or inside another container (nested Docker, common in CI), the socket permissions are set at daemon start time based on whatever &lt;code&gt;/etc/group&lt;/code&gt; snapshot the daemon sees—which may not reflect the group membership you just added.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Root Cause &amp;amp; Runnable Fix
&lt;/h2&gt;

&lt;p&gt;The issue has three layers:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Group membership isn't inherited by existing processes
&lt;/h3&gt;

&lt;p&gt;After &lt;code&gt;usermod -aG docker $USER&lt;/code&gt;, your &lt;strong&gt;current shell session&lt;/strong&gt; still has the old group list. You must:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Force the current shell to reload group membership&lt;/span&gt;
&lt;span class="nb"&gt;exec &lt;/span&gt;su &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="nv"&gt;$USER&lt;/span&gt;
&lt;span class="c"&gt;# or just&lt;/span&gt;
newgrp docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But in automated CI runners or systemd services, there's no interactive shell to reload.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The socket can be owned by root:root instead of root:docker
&lt;/h3&gt;

&lt;p&gt;If &lt;code&gt;dockerd&lt;/code&gt; starts before the &lt;code&gt;docker&lt;/code&gt; group exists (race condition on boot or in ephemeral VMs), it falls back to &lt;code&gt;root:root&lt;/code&gt; with &lt;code&gt;0600&lt;/code&gt; permissions.&lt;/p&gt;

&lt;p&gt;Fix: explicitly set socket group in &lt;code&gt;/etc/docker/daemon.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"group"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"docker"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"live-restore"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart daemon:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart docker
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; /var/run/docker.sock
&lt;span class="c"&gt;# Now: srw-rw---- 1 root docker&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Nested Docker or rootless mode requires host socket forwarding
&lt;/h3&gt;

&lt;p&gt;If you're running Docker inside a container (CI agent in Docker, docker-in-docker), mounting &lt;code&gt;/var/run/docker.sock&lt;/code&gt; isn't enough. The container's user must have matching UID/GID or CAP_DAC_OVERRIDE.&lt;/p&gt;

&lt;p&gt;Production-hardened &lt;code&gt;docker-compose.yml&lt;/code&gt; for CI agents:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3.9"&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;ci-agent&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-ci-agent:latest&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1000:999"&lt;/span&gt;  &lt;span class="c1"&gt;# UID 1000, GID 999 (docker group on host)&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/var/run/docker.sock:/var/run/docker.sock:rw&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;DOCKER_HOST&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unix:///var/run/docker.sock&lt;/span&gt;
    &lt;span class="na"&gt;group_add&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;999"&lt;/span&gt;  &lt;span class="c1"&gt;# Explicitly add docker GID&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key fix: &lt;code&gt;group_add: ["999"]&lt;/code&gt; ensures the container process gets the &lt;code&gt;docker&lt;/code&gt; group even if the image doesn't have it baked in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 3-Line Verification Script
&lt;/h2&gt;

&lt;p&gt;We added this to our provisioning playbook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail

&lt;span class="c"&gt;# Verify daemon is reachable without sudo&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; docker info &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null 2&amp;gt;&amp;amp;1&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"FATAL: Docker daemon unreachable. Socket: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; /var/run/docker.sock&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Current groups: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="nt"&gt;-nG&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi

&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"✓ Docker daemon accessible"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Runs immediately after provisioning. If it fails, we know the socket setup is broken before any builds start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Invariant Rule
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Never assume group membership propagates automatically.&lt;/strong&gt; On every Docker daemon restart or VM reboot:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Verify &lt;code&gt;/var/run/docker.sock&lt;/code&gt; ownership is &lt;code&gt;root:docker&lt;/code&gt; with &lt;code&gt;0660&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If using containers that need Docker access, pass &lt;code&gt;group_add: [&amp;lt;docker-gid&amp;gt;]&lt;/code&gt; explicitly in compose or &lt;code&gt;--group-add&lt;/code&gt; in &lt;code&gt;docker run&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In CI pipelines, run &lt;code&gt;docker info&lt;/code&gt; as a health check before any build step.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We eliminated 90% of our "Docker permission denied" oncall pages by enforcing these three checks in our VM image baking process.&lt;/p&gt;

&lt;p&gt;No more 3 AM socket archaeology.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
