Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

Reduced a Docker image from 1.37GB → 168MB. Just by using multi-stage builds, slim base images, and cleaning unused dependencies. Small optimizations = faster CI/CD and safer containers.

157,277 Aufrufe • vor 3 Monaten •via X (Twitter)

0 Kommentare

Keine Kommentare verfügbar

Kommentare vom Original-Post werden hier angezeigt

Ähnliche Videos

You are using Docker wrong. I promise! Here are the two things you are missing out: • Your Dockerfiles are using a single stage. This is very slow. • You aren't caching steps as much as you could. This is also slow. For a couple of years now, Docker has been using BuildKit as its primary engine, which has added support for multi-stage Dockerfiles. Here's the deal: A single-stage Dockerfile (the one you are likely using) forces every step to depend on the previous one. That means: • Everything runs sequentially • The generated image is huge • Any change will skip cached layers • No opportunities to parallelize steps Changing one line early in the Dockerfile renders everything after it useless. There's a better way: Start using multi-stage builds. I recorded the attached video to illustrate a comparison between a slow, single-stage build and a fast, multi-stage build. Here is what you need to do: Split your Dockerfile into independent stages using multiple FROM statements. BuildKit will turn those stages into a dependency graph and run independent stages in parallel. There are several benefits to this: 1. The build process will be way faster. Parallelizing independent stages will save a massive amount of time. 2. You'll get way better caching. Each stage has its own set of layers. If something changes in your build stage, your final stage doesn't get invalidated. get clean final images. You don't need to ship tooling, compilers, or temporary files. You'll only copy to the final image what you need. This has been a massive upgrade to the way I structure my Dockerfiles.

Santiago

67,694 Aufrufe • vor 7 Monaten