1. From image to first run: six building blocks and one rule

Practical Docker work comes down to six building blocks and one rule: separate disposable code from durable state. (For Linux kernel mechanics and local overhead benchmarks, see the companion article: The Same ELF Binary, a Different World →.)

  1. Recipe (Dockerfile) and registry — an author writes installation steps (base OS, libraries, code) in a plain-text Dockerfile, builds a package and publishes it to a registry (an online warehouse of ready-made images such as Docker Hub or ghcr.io).
  2. Image — a sealed, immutable template downloaded from a registry (pinned by a sha256 digest). It is read-only and does nothing by itself — much like a program’s installation files sitting on disk.
  3. Container — a live, running instance of that image. It is deliberately disposable: when an update arrives or a service misbehaves, you throw away the container and launch a fresh one from the image in seconds, just as you do not hesitate to reinstall an app as long as your documents sit in a separate folder.
  4. Persistent data: bind mounts (:ro) and volumes — to keep source files, settings or databases from vanishing when a container is deleted, attach durable host storage instead of writing inside the ephemeral upperdir layer. A bind mount exposes an explicit host folder (:ro locks writes like an SD card switch), whereas a named volume delegates storage management to Docker for databases; on Linux, pass --user "$(id -u):$(id -g)" (or user: in Compose) when writing to bind mounts so files are not created as root:root. The table below the Compose example compares all three storage locations.
  5. Port mapping (127.0.0.1:8081:8080) — each container gets its own private network. Writing 127.0.0.1:8081:8080 forwards port 8081 on your host’s loopback interface to port 8080 inside the container, while services inside the same Compose file talk directly by service name (db:5432) without publishing ports to the host. Prefixing 127.0.0.1: is deliberate: plain 8081:8080 binds 0.0.0.0 across every network interface, and on Linux Docker’s iptables/nftables NAT rules bypass standard ufw input rules — easily exposing an unauthenticated local service to the LAN or internet.
  6. Docker Compose (compose.yaml) — instead of typing long docker run commands from memory, you declare services, ports and attached storage in one readable compose.yaml file:
services:
  adminer:
    image: adminer:5
    ports:
      - '127.0.0.1:8081:8080'
  db:
    image: postgres:16
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD in .env}
    volumes:
      - ./archive:/import:ro
      - pgdata:/var/lib/postgresql/data
volumes:
  pgdata:

This runs PostgreSQL alongside Adminer so you can query the database from a browser. Next to compose.yaml, create the archive directory and set DB_PASSWORD in a local, untracked .env file. Once the services are up, open http://127.0.0.1:8081, choose PostgreSQL, enter db as the server and sign in as postgres with that password. The three storage locations each serve a different purpose.

Storage locationWhere files physically liveSurvives down / rm?When to use it
Inside the container (upperdir)Temporary writable layer of one instanceNo (deleted with container)Scratch files only; never databases or personal documents
Bind mount (host folder)Explicit host folder visible in your file managerYesYour own files (CSVs, documents, GGUF weights); :ro locks writes like an SD card switch
Named volumeManaged directory on the host controlled by DockerYesDatabases (PostgreSQL, SQLite) and app state across upgrades

Four commands cover the everyday lifecycle of that file:

  • docker compose up -d — downloads any missing images, creates the project’s private network and starts services in the background (-d).
  • docker compose logs -f — streams live service logs (the first place to look when something fails to start).
  • docker compose pull && docker compose up -d — pulls newer images and swaps out only the containers in seconds while keeping attached data intact.
  • docker compose down — stops and removes the containers and project network, leaving all bind-mounted folders and named volumes (pgdata) untouched.
Practical Docker model: a registry or Dockerfile produces a read-only OCI image, from which compose up -d launches a disposable container connected outward through port mapping (127.0.0.1:8081 to 8080), a read-only :ro bind mount and a durable pgdata database volume, all wired together by compose.yaml. Enlarge illustration ↗
01. Docker building blocks in one view. The OCI image is a read-only template, the container is an ephemeral runtime instance, and ports, host folders (:ro) and durable volumes are wired together by compose.yaml.

The tools and the size of the data will change over the next few examples. I keep coming back to one question. If I remove this container tomorrow, what will I need to get back to work?

2. Personal machine and home archive: zero system clutter and safe files

Containers do not require a server rack or Kubernetes. On an ordinary desktop or mini-PC, they solve three very mundane problems: leftover clutter from one-off tools, fear of damaging irreplaceable files, and the pain of rebuilding everything from memory when replacing hardware.

A PDF from Markdown without installing TeX Live

You’ve written a report in Markdown and someone needs a PDF with the tables and equations intact. For a one-off export, you can borrow the typesetting tools for the length of a single command. The official pandoc/latex image includes Pandoc and enough of TeX Live to produce a typical PDF. From the directory containing report.md, run:

docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/data" \
  pandoc/latex report.md -o report.pdf

You’ll find report.pdf next to the source. Docker removes the container on exit because of --rm and keeps the downloaded image for next time. The same approach works for extracting the audio from a recorded lecture with FFmpeg. OCRmyPDF works much the same way when an existing PDF needs a searchable text layer. It can take the document on standard input and send the result to standard output, so you can skip the directory mount altogether.

Can you still find last winter’s coldest morning after a move?

Suppose your home weather station writes out a CSV of temperatures every month. Put one month’s file in the archive directory from the Compose example. PostgreSQL sees the file under /import and can read it into a table with COPY FROM. If you get the units wrong in a conversion, discard the affected rows and repeat the import. The :ro mount protects the source file from writes by the container.

Before replacing the computer, jot down the date and temperature of last winter’s coldest morning. Move the CSVs, the Compose configuration and a pg_dump backup. Restore the database on the new machine, run the same query and open the source file for that month. Adminer will show its login screen even if the database is empty. Finding that morning’s reading tests whether you actually brought the archive across.

An old mini-PC as a home archive and media server (Jellyfin and ArchiveBox)

With the exact same building blocks, an old mini-PC becomes a tidy home appliance in one afternoon (with restart: unless-stopped in compose.yaml so services come back automatically after a power outage without SSH intervention):

  • Jellyfin in a container: media library mounted read-only (:ro), configuration in a separate directory. The practical payoff arrives during minor upgrades: if a newer release stops playing subtitles properly on the living-room TV, changing one line in compose.yaml rolls the server back in seconds. Before a major release, back up the configuration directory first because Jellyfin also migrates its own SQLite database.
  • ArchiveBox: a local archive of web pages and service manuals for older equipment that tend to vanish from the web without warning. Simple verification: save a service manual, disconnect the network, and verify that the local snapshot retains the schematic you actually need for repair rather than bare text with broken image links.
A weather archive in PostgreSQL. The database container reads source CSVs through a read-only mount at /import and writes its tables to a separate pgdata volume. Moving the archive requires restoring both the database and the source files. Enlarge illustration ↗
02. Separating ephemeral code from durable state. You replace the container from a cached image in seconds; a :ro mount guards the originals, while the database and configuration need their own consistent backup strategy.

3. Workstation: version conflicts, local AI and resource control

On a workstation juggling multiple tool versions, local language models and heavy background workloads, the exact same primitives give you precise control over networking, storage and hardware resources.

Two conflicting versions of the same service on one laptop

Classic multi-project friction: Project A needs an older version of a service on port 8080, while Project B requires a newer, incompatible version on the exact same port with different data. Under Docker Compose networking, each project receives its own isolated network namespace and embedded DNS server.

As a result, two separate Compose projects can share the exact same internal service name and port (for instance http://result:8080/id), with a client in Project A reaching instance A and a client in Project B reaching B — with zero port rewriting in application code and no host library conflicts. One important caveat: that applies inside the container networks. When publishing both services to the host browser via ports, you still map them to distinct host ports (such as 127.0.0.1:8081:8080 and 127.0.0.1:8082:8080) to avoid a host-side bind conflict.

Two LLM engines, one copy of weights and selecting a GPU by UUID

In my local language-model experiments (covered separately in n-grams and memory across SSD, RAM and VRAM and memory physics and LLM inference hardware), a single GGUF weight file can easily span tens or over a hundred gigabytes. Duplicating it just to compare two releases of llama.cpp makes no sense.

Instead, I mount the same GGUF file read-only (:ro) into two containers carrying different llama.cpp builds and run llama-bench sequentially on the same GPU, comparing prompt-processing (prefill) and generation (decode) speeds under identical conditions. SSD footprint stays fixed at one copy of the weights while VRAM usage is tracked independently.

When a workstation holds two identical GPUs, NVIDIA Container Toolkit lets you pin a specific card unambiguously by UUID (--gpus '"device=GPU-…"', where you can read each card’s UUID via nvidia-smi -L) and verify inside the container that the renderer or inference engine sees only that card. One important technical nuance: granting device visibility is not a hard VRAM reservation — if two containers are pointed at the same GPU concurrently, they still contend for its memory and CUDA streams.

Two workstation setups: left shows two Compose projects with separate networks where http://result:8080/id returns A and B; right shows two llama.cpp versions sharing one read-only GGUF weight file and assigned to GPU-0 by UUID. Enlarge illustration ↗
03. Keeping a workstation tidy. Left: DNS and internal port isolation across Compose networks (A vs. B). Right: comparing two llama.cpp versions on one read-only GGUF file pinned to a GPU by UUID.

Four quick diagnostic habits

  1. “I have 10 images at 1 GB each — how much SSD space will I actually reclaim?” Instead of going by the raw sum in docker image ls, run docker system df -v and read SHARED SIZE versus UNIQUE SIZE. Because OCI layers are deduplicated by SHA-256 (detailed in the kernel & overhead article), deleting one image frees only its UNIQUE portion.
  2. Adjusting CPU budgets mid-build: when a long background compilation starts starving your laptop, you do not have to abort it. Running docker update --cpus 0.5 name updates cpu.max in cgroups v2 on the fly — and for future runs you can record that cap in compose.yaml (keeping cgroups v2 multithreaded throttling in mind).
  3. Does this tool genuinely work offline? Pull the image ahead of time and run one real task against a fresh working volume (with no pre-populated host cache) using --pull=never --network none (the none network driver). It is a straightforward check for “silent” runtime dependencies — catching programs that try to download a model, dictionary or font on first invocation.
  4. Terminal on a laptop, heavy lifting on a desktop workstation: with Docker contexts over SSH, you type commands on a light laptop while image builds or media processing execute on a beefy desktop under the desk where the data already sits. The practical gotcha almost everyone hits once: a bind-mount source path resolves on the machine running the Docker daemon, not on the laptop where you typed the command.

In practice — run an offline check before traveling or shipping: If a tool needs to work on a train, in the field or on an air-gapped PC, test it once on a real input file with --pull=never --network none. Having pulled the image ahead of time does not prove the program will not reach out to the internet at runtime.

4. Product engineering: a reproducible lab and legacy hardware

Three years after a board ships, someone asks for a small fix. You still have the source, but which compiler built the last release? The same question comes up when testing an application without the device on hand or sending a board revision out for fabrication. In each case, you can keep enough information in the project for someone else to repeat the work.

Patching a three-year-old board (ESP-IDF) and using Docker as an artifact compiler

A customer asks for a small firmware fix on a board designed three years ago. Your current workstation already runs newer GCC, Python, CMake and a completely different SDK. Trying to reconstruct the old toolchain natively on the host usually ends up breaking today’s projects.

Microcontroller vendors — such as Espressif with official, versioned ESP-IDF images — package the exact SDK, compiler and build scripts into a single image. You can compile the same source with the old and new toolchains side by side, diff the resulting .bin files and linker maps (seeing exactly how many bytes of Flash and SRAM changed), and test both builds on real hardware.

A practical extension of this pattern is using BuildKit as a hermetic compiler that never produces a runtime image at all, only exporting the finished firmware straight to disk (BuildKit local exporter). The final stage of a multi-stage Dockerfile (FROM scratch) copies only the .elf, .bin and linker map files, and --output type=local,dest=./out drops them directly into ./out — ready for the production flasher:

docker buildx build --target firmware-artifacts --output type=local,dest=./out .

How do you test the app when the scale is back at the warehouse?

Suppose a shipping app reads parcel weights from a scale over HTTP. You want to check what happens to a parcel weighing exactly 5 kg. On a laptop, put a response in the device’s usual format in fixtures/weight.json, for example {"grams": 5000}. Add a service to your test compose.yaml to serve that file:

services:
  scale:
    image: nginx:stable-alpine
    volumes:
      - ./fixtures:/usr/share/nginx/html:ro

Run docker compose up -d scale and point the app, running on the same Compose network, at http://scale/weight.json. With an inclusive 5 kg limit, the app should accept the parcel. Change 5000 to 5001 in the file and take another reading. This time it should flag the parcel as overweight. You can check both cases without plugging in a scale or hunting down a one-gram weight.

From KiCad project to PCB fabrication files in one command

The board house needs Gerbers and drill files, the assembler wants a bill of materials (BOM), and you want a view of the board from the connector side. Set up those exports once in KiCad. Save their settings and output directory in release.kicad_jobset and commit it alongside the project, schematic and board. From the project directory, run the KiCad CLI jobset:

docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" -w /work \
  --entrypoint kicad-cli kicad/kicad:9.0.7 \
  jobset run --stop-on-error --file release.kicad_jobset controller.kicad_pro

Gerbers and drill files come from the board layout. Component counts in the BOM come from the schematic. For a 3D render, the component models must be available at the paths recorded in the project. Run the same KiCad image on a laptop or in CI, and on the next revision nobody has to remember which layers were ticked in the export dialog.

Reproducible experiments and scientific results

Two years from now, a colleague might open your CSV, run the same script and get a different result. Was it the input, a calibration coefficient or a library update? I’d send four things with the analysis: the raw readings, the calibration parameters, the processing image digest and one expected result. CERN Open Data takes a related approach by providing analysis environments for specific years of CMS data.

Freeze a working toolchain before the downloads disappear

You reopen an old project. Git still has the code and requirements.txt still names the exact version. The binary download link is dead, though, and on your new Python the installer tries to compile a dependency that used to come as a wheel. While the project still works, you can keep a fork of the environment you can actually run. docker image save writes the image layers, runtime configuration and local tag to a TAR file. That preserves the bytes of the interpreter, installed Python packages, CLI executables and shared libraries (.so). A build environment can also carry the headers and static archives (.a) you need to link an old program.

Take a working image tagged yaml-tools:golden that contains the Python version of yq and the jq executable it calls. Keep a golden sample alongside the image. Here the input is one line of YAML, and the expected output of the .tries filter is the number 3:

printf 'tries: 3\n' > sample.yaml
printf '3\n' > expected.txt
docker image save -o yaml-tools.tar yaml-tools:golden
sha256sum yaml-tools.tar sample.yaml expected.txt > SHA256SUMS

Store those four files on a backup drive. Try restoring them on another machine with a compatible CPU architecture and a Linux container runtime. With Docker, docker image load restores the tagged image from the archive:

sha256sum -c SHA256SUMS
docker image load -i yaml-tools.tar
docker run --rm -i --pull=never --network none --entrypoint yq \
  yaml-tools:golden '.tries' < sample.yaml > actual.txt
cmp expected.txt actual.txt

The checksums tell you whether the files arrived intact. cmp answers a different question: do the copies of Python, yq, jq and their libraries still produce the expected result together? You can run that check after the package release, distribution repository or container registry has disappeared.

Sometimes the only working installation is a container somebody patched by hand. Capture those changes first with docker container commit container-name yaml-tools:golden, then run save. This captures files and configuration. On restore, the process starts from the beginning. Back up any code or data in bind mounts and volumes, and any external database, separately.

5. Talking between the native host and a container: networks, pipes, mmap and synchronization

HTTP works well for an ordinary API. Projects such as INVOLV3D also have to move raw frames. For a sense of scale, suppose a native C++ driver receives 12 MP camera frames and Python code in a container needs to read them. With uncompressed RGB at eight bits per channel, 12 million pixels × 3 bytes = 36 MB per frame. At 30 frames per second, that’s 1.08 GB/s of payload. Each extra full-buffer copy reads and writes another 36 MB per frame. I cover the path from device to RAM in the article on I/O and DMA.

At that point, Linux kernel namespace mechanics give you three distinct channel tiers between the host and a container:

ChannelPayload copyingWorks with --network none?When to choose it
TCP / HTTP (bridge or --network host)Repeated socket-buffer and TCP/IP stack copies (bridge adds veth + NAT)NoOrdinary APIs, JSON, telemetry and services that may move to separate machines
Named pipes (fifo(7)) & Unix sockets (unix(7), .sock) via bind mountBytes copied through a kernel buffer, bypassing TCP/IP and NATYes (shared directory)Local byte streams and lightweight control messages (how docker talks to dockerd — avoid mounting docker.sock into app containers)
Shared memory (mmap(2) on tmpfs or /dev/shm)Zero-copy on native Linux (shared RAM pages via MAP_SHARED)Yes (shared tmpfs or --ipc)Raw camera frames, large tensors and high-throughput measurement buffers

A Unix socket or named pipe in a bind-mounted directory works fine for sending a buffer index. Send the contents through it too, and the bytes pass through a kernel buffer. With mmap(..., MAP_SHARED, ...), both processes on native Linux can access the same pages of a file on tmpfs. The producer fills a free slot and sends its index. The consumer releases the slot once it has finished reading. The same design fits blocks of I/Q samples from a software-defined radio (SDR), readings from a data acquisition (DAQ) card, real-time audio buffers or a simulation feeding each time step to a Python model. On Docker Desktop for Windows and macOS, a virtual machine sits between the host process and the container.

Three practical synchronization and resource pitfalls

Switching to shared memory and local IPC solves bandwidth bottlenecks, yet three concrete traps catch almost everyone the first time:

  1. Private 64 MB /dev/shm vs. host-shared tmpfs: Docker limits a container’s private /dev/shm to 64 MB by default. Inside a container (such as a multi-worker PyTorch DataLoader or containers sharing --ipc=container:…), raising it with --shm-size (shm_size in compose.yaml) prevents No space left on device errors and SIGBUS crashes when touching mmap pages. That private /dev/shm, however, is invisible to native host processes. For host ↔ container zero-copy, bind-mount a directory on host tmpfs (for instance -v /dev/shm/camera:/dev/shm/camera or -v /run/camera:/run/camera) or use --ipc=host (which ignores --shm-size and uses the host’s /dev/shm size). In cgroups v2, tmpfs pages are charged by first touch to whichever cgroup allocates and writes a page first — a buffer populated inside the container counts toward its memory.max, whereas a buffer created and filled by a native host driver charges host RAM.
  2. Semaphores in separate ipc namespaces and SIGKILL deadlocks: mmap alone does not tell the reader when a frame write has finished. On Linux, POSIX named semaphores (sem_overview(7), sem_open) create files under /dev/shm/sem.*, so without a shared /dev/shm or explicit IPC sharing (--ipc=host / --ipc=container:…), host and container open two completely separate semaphores with the same name and hang. Worse, a plain mutex placed inside shared memory (PTHREAD_PROCESS_SHARED) leaves the peer permanently deadlocked if the lock-holding process is killed by SIGKILL (such as OOM or docker kill). The most resilient pattern in practice is a hybrid: keep bulk pixels in an mmap ring buffer and send tiny “frame ready in slot #3” notifications over a Unix socket or FIFO — if one peer crashes, the kernel closes the file descriptor immediately (EOF / EPIPE) instead of hanging the survivor (alternatives include PTHREAD_MUTEX_ROBUST or a lock-free SPSC ring buffer).
  3. Mount the parent directory (never a single .sock file), UID/GID permissions and PID isolation: for .sock and FIFO endpoints, always bind-mount the parent directory (such as /run/camera:/run/camera), not a single socket file — if the host service restarts and recreates the socket (unlink() + bind()), a single-file bind mount stays pinned to the dead, orphaned inode until the container restarts. In addition, .sock, FIFO and mmap files obey standard Linux permissions (--user UID:GID), and without --pid=host a container cannot see host PIDs or send signals directly to them.

6. Delivering a service to a site with no registry access

Suppose you’re packaging lab-service:2.4.0 for an isolated network in a research lab, hospital, power station or factory. On a ship, the connection to shore might simply be unavailable during installation. In each case the service has to produce its first result using only what you bring with you.

Step 1. What goes on the installation media?

On a machine with registry access, put together four things:

  1. An archive of images built for the customer’s architecture exported via docker image save (the same pattern used by K3s air-gap installs) — when preparing an ARM bundle on an x86-64 laptop, explicitly pull or build with --platform linux/arm64,
  2. A compose.yaml referencing local image names and pinned versions,
  3. Configuration files and any model weights,
  4. One acceptance sample, such as a minute of sensor readings with a known sample count and maximum value.

Save the example image with docker image save -o lab-service.tar lab-service:2.4.0. On the target machine, docker image load -i lab-service.tar restores the local tag. Before you leave, try the installation on a second, disconnected computer and time how long it takes to get the expected result. If Compose needs a database image as well, you’ll discover that while you’re still at your desk.

Step 2. One release number for x86-64 and ARM

Suppose the customer deploys x86-64 PCs in batch one, then adopts ARM (arm64) units six months later. Using multi-platform builds (OCI Image Index), you publish one release tag backed by two distinct manifests and two native layer stacks — and run the acceptance sample on both physical machines (keeping in mind from the CPU architectures article why QEMU emulation cannot substitute for real silicon verification).

Over slow field connections, update size matters. Because layers are content-addressed by SHA-256, a site that already holds the previous release downloads only missing blobs from the OCI manifest. Comparing full image size against the missing-blob delta quickly instills Dockerfile hygiene: heavy dependencies near the bottom, fast-changing application code at the top.

If you also need to patch the base image (for a security fix) without re-copying large, unchanged static directories, look at COPY --link. With a compatible backend and independent layers, BuildKit can rebase a new manifest out of existing blobs, saving both build time and transfer bandwidth.

Step 4. How does support recover the exact application and library versions?

Months after installation, an edge case appears on site. So support never has to guess what is actually running (since a mutable :2.4 tag could have moved in the meantime), generate and archive a digest-locked file at every handover with docker compose config --lock-image-digests. That lets support reproduce the exact image stack bit for bit.

And when an enterprise customer’s security team asks on Friday afternoon, “Which exact OpenSSL version did you ship in this release?”, the answer comes from BuildKit SBOM (Software Bill of Materials) and provenance attestations. Instead of digging through a live container, you query the package inventory attached to that exact digest — and verify during release acceptance that key libraries appear properly in the SBOM.

Step 5. Limits of rolling back after a database migration

Finally, the most important commercial caveat worth keeping in mind before relying on fast image rollbacks. Imagine deploying a new version on Monday alongside a PostgreSQL schema migration (altered columns, new tables), then getting a request on Wednesday to revert immediately to Friday’s release.

Swapping cached container images back takes only seconds — yet the older application may not understand the migrated database schema, while restoring Friday’s backup (pg_dump / pg_restore) wipes out every measurement collected on Monday and Tuesday. Always rehearse post-migration rollback on a staging copy before shipping: verify reading a specific pre-migration record and define in advance how post-migration data is handled (for instance through backward-compatible, expand-and-contract migrations). Containers solve code versioning cleanly — they never remove engineering responsibility for data evolution.

Commercial BuildKit delivery pipeline: one source repo produces firmware binaries, a multi-platform amd64/arm64 OCI index with locked digests, and SBOM attestations, feeding an application test with a simulated scale, an offline installation from removable media, and an online delta registry. Enlarge illustration ↗
04. One source to the customer. BuildKit emits firmware binaries (--output), a digest-locked multi-platform index and SBOM attestations, feeding tests with simulated hardware, air-gapped sites and delta registry updates alike.

7. Four lesser-known Docker features useful in practice

Beyond the headline workflows, a few lesser-known Docker and containerd capabilities fall directly out of OCI layer and Linux kernel mechanics, paying off in specific situations:

  1. Recover a report from a stopped container. An import crashed halfway through, and the next run will overwrite the list of rejected rows. As long as the stopped container named importer still exists, docker cp importer:/tmp/rejected.csv . will retrieve the report. This works for jobs started without --rm.

  2. Give a dictionary its own image. When a hyphenation engine needs a new dictionary, ship the data as a separate OCI image. With the containerd image store, you can mount that image read-only inside the application container. The program and dictionary each get their own version. If somebody reports an odd line break, you can reproduce the exact pair that split the word.

  3. One address for an entire multi-service stack (Compose as an OCI artifact): instead of emailing a zipped bundle of YAML files to a customer with registry access, you can publish the Compose file itself as an OCI artifact in the registry and launch it with a single docker compose -f oci://… up (provided the stack references prebuilt images rather than local build contexts).

  4. Bring a toolbox alongside a running service. The app container uses a distroless or scratch image. You want to check which port it’s listening on, but it doesn’t even have sh. Start netshoot alongside it:

    docker run --rm -it --network container:app --pid container:app nicolaka/netshoot

    From this shell, ss -lnt lists the listening ports in the application’s network namespace and ps -ef shows its processes. The tools come from the debug container’s own filesystem. Type exit and Docker removes the toolbox while the service keeps running.

8. When containers add friction (and native execution is simpler)

Containerization solves dependency conflicts and reproducibility, yet in four technical situations it adds more overhead or indirection than benefit:

  1. A single small Python CLI on a local machine: when isolated Python packages for one command-line tool are all you need, pipx install creates a clean environment with minimal overhead. The gap is widest on Windows and macOS, where Docker Desktop must keep a full virtual machine and file bridge running for a brief command.
  2. Interactive debuggers, programmers and boards over USB: locking the firmware compiler toolchain inside a versioned image works well (as in Section 4), whereas interactive vendor debuggers and frequent USB re-plugging rely on direct host port access. Under Docker Desktop, USB passthrough via USB/IP introduces an extra configuration layer whose reliability varies across drivers and hardware.
  3. Measuring hard latency budgets on a target ARM board: when a design or purchasing decision depends on whether a single-board computer can calculate a new control output before the next cycle, the baseline should be measured natively on the target silicon first and only then verified inside the target container setup. QEMU ARM emulation on an x86-64 PC measures binary translation overhead, not the board’s real performance.
  4. Running untrusted, potentially hostile code: as shown in the kernel mechanics and overhead article, every native Linux container shares the host kernel. Whenever the security boundary must be a separate kernel (not merely isolated dependencies), hardware virtualization — a full virtual machine or microVM — is required.

In practice — a quick checklist before running docker run:

  1. Valuable immutable data (source files, recordings, GGUF weights)? Always mount :ro.
  2. Mutable data and databases? Always on a volume or bind mount — never in upperdir.
  3. Customer delivery or reproducibility test? Lock versions with --lock-image-digests, attach an SBOM and verify --pull=never --network none.
  4. Database migration? Rehearse data rollback (pg_dump/pg_restore) first before counting on an instant image revert.
  5. Tiny CLI, physical USB debugger or target ARM timing? Running it natively is simpler and more direct.

9. Sources and further reading

Personal machine and workstation workflows

Product engineering, host–container IPC and reproducibility

Commercial delivery, workshop patterns and native boundaries