Tech News
← Back to articles

Docker Superpowers You Forget to Use

read original related products more articles

Docker has been around long enough that most teams treat it as solved tooling, yet I still uncovers the same underused features. Here are ten practical capabilities that rarely make it into day-to-day workflows but pay reliability and velocity dividends immediately.

1. Multi-stage builds keep prod images tiny

Ship only what you need. Use a heavy build stage for toolchains and a clean runtime stage so you do not leak compilers and caches into production layers.

FROM node:22 AS build WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM gcr.io/distroless/nodejs22 COPY --from=build /app/dist /app CMD ["server.js"]

Pair this with --target when you need to run CI tasks inside intermediate stages without bloating the final artifact.

2. BuildKit cache mounts turn npm ci into milliseconds

Enable BuildKit ( DOCKER_BUILDKIT=1 ) and add cache mounts so expensive steps reuse artifacts across builds.

RUN --mount=type=cache,target=/root/.npm \ npm ci --prefer-offline

Treat cache mounts like shared volumes: never bake secrets into them and periodically invalidate them with --build-arg CACHE_BUST=$(date +%s) when dependencies change.

3. Secrets stay out of layers with RUN --mount=type=secret

... continue reading