| Ko

Multi-container development with Docker Compose

Running a web app, a DB, and a cache each with docker run means memorizing long commands per container and wiring up networks by hand. The more common problem is that the app comes up before the DB is ready and dies on a connection error. Docker Compose declares the whole stack in one YAML file and brings it up with a single command. The thing that actually trips you up with multiple containers is service startup order. The stack below starts the app only after the DB is ready. Running docker compose up confirms the order holds in the log. The output comes from a run on Docker Compose v5.1.1. ...

February 17, 2025 · 4 min · 816 words · In-Jun

Optimizing Docker Image Size

Docker image optimization affects build times, deployment speed, storage costs, and the security profile of containerized applications. By choosing the right base image, using multi-stage builds, and cleaning up layers, you can often shrink an image by 10x or more while also improving CI/CD throughput and reducing cloud infrastructure costs. Understanding Docker Image Size Problems Why is Image Size Important? Docker image size directly affects build time, push/pull time, container startup time, storage costs, and attack surface. Image optimization is essential for efficient operations in production environments. ...

February 17, 2025 · 8 min · 1677 words · In-Jun

Docker image layers and caching

Change one line of source and the rebuild runs npm install from scratch. An image is a stack of layers, and Docker caches build results layer by layer. When one layer is invalidated, everything below it rebuilds too. So the order of instructions in a Dockerfile determines build speed. The sections below build images, catch the cache breaking in the docker build log, and measure how an ordering change moves the build time. Every output comes from a run on Docker 29.3.1. ...

February 17, 2025 · 6 min · 1134 words · In-Jun
[email protected]