<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Docker on Besterry — Linux &amp; DevOps Notes</title><link>https://besterry.com/tags/docker/</link><description>Recent content in Docker on Besterry — Linux &amp; DevOps Notes</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 20 May 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://besterry.com/tags/docker/index.xml" rel="self" type="application/rss+xml"/><item><title>Reducing Container Image Size: Multi-Stage Builds and Alpine</title><link>https://besterry.com/posts/container-image-size/</link><pubDate>Mon, 20 May 2024 00:00:00 +0000</pubDate><guid>https://besterry.com/posts/container-image-size/</guid><description>&lt;p&gt;Small images boot faster, save bandwidth, and have smaller attack surface. Here are the techniques that actually work.&lt;/p&gt;
&lt;h2 id="multi-stage-builds"&gt;Multi-stage builds&lt;/h2&gt;
&lt;p&gt;The single biggest win. Build in one stage, copy only the artifacts to a minimal runtime stage. A Go binary of 15 MB ends up in a 17 MB image. Compare to a naive golang:1.22 image at 900+ MB.&lt;/p&gt;
&lt;h2 id="base-image-choice"&gt;Base image choice&lt;/h2&gt;
&lt;p&gt;From smallest to largest for Go/Rust static binaries:&lt;/p&gt;</description></item><item><title>Docker Network Debugging: nsenter and tcpdump Patterns</title><link>https://besterry.com/posts/docker-networking/</link><pubDate>Wed, 20 Mar 2024 00:00:00 +0000</pubDate><guid>https://besterry.com/posts/docker-networking/</guid><description>&lt;p&gt;When a container cannot reach something, the instinct is often to exec into it and curl. But most slim containers lack curl, dig, tcpdump, or even ping. A better pattern: use nsenter from the host.&lt;/p&gt;
&lt;h2 id="enter-the-container-network-namespace"&gt;Enter the container network namespace&lt;/h2&gt;
&lt;p&gt;Get the container PID:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;docker inspect -f '{{.State.Pid}}' myapp
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nsenter -t PID -n bash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You are now in the container network namespace, but with the host binaries. tcpdump, ip, ss, dig — all work.&lt;/p&gt;</description></item></channel></rss>