docker: multi-stage builds (intermediate) anthony explains #503

preview_player
Показать описание
today I talk about docker multi-stage builds -- why they're useful, and yet why I tend to avoid them!

==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

I use multi-stage builds for python at work, to save disk space mostly. Why? Those images are pulled on IoT LTE connection with scarce limits, so smaller = better

dstinYwOw
Автор

I mostly use multistage builds for the security aspects. Most of my build require that I provide credentials to access external resources.
In these situations you don't want your credentials in the final image. Newer versions of docker have ways of passing in secrets. But our IT department refuses to update the version we use so multi state build it is

putnam
Автор

Any logical use case of using multi-stage for Python apps ? I mean for languages like Go, C, Rust etc where you have build artifacts as a binary output it makes absolute sense to reduce image size

BakhtiyarGarashov
Автор

For me caching in multistage build works. As I have notices, you will have rebuilds of first stage where you have changes: e.g. if you cp reqeuests.txt that is different from what was before, all later layers will be rebuild, otherwise docker will check later commands to find changes if any. So, if you want to optimize build time, put things that will change frequenty to the end to cache more layers.

RuslanKovtun
Автор

Please explain Nix vs Docker, in terms of convenience for a long-term project which you want to always work, even if you build it 5-10 years later.

manuel_youtube_ttt
Автор

Your views are critically low for as good a channel you are! Thanks!

Phaust
Автор

Dockerfile:
FROM ubuntu:jammy

RUN : \
&& apt-get update \
&& apt-get install -y --no-install-recommend
gcc \
libc6-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*


COPY main.c .

RUN gcc -o main.c

Hi when I try to build image i recieve next error:
ERROR: failed to solve: dockerfile parse error on line 6: unknown instruction: gcc
Can you explain please what I am doing wrong ?

And if it not secret what keyboard model do you use ?

sammygun