Day-26 | Multi Stage Docker Builds | Reduce Image Size by 800 % | Distroless Container Images |
Вставка
- Опубліковано 1 жов 2024
- Support my work
www.buymeacoff... Hi Everyone, Today's Class I am going to talk a real time production scenario that you can explain in an interview. You can use the example demonstrated in the video and try out multi stage docker builds and distroless images on your applications.
We will learn in this video:
==============================
1. Multi Stage Docker Builds
2. Reduce Docker Image Size
3. Distro Less Images
4. Containers Security
5. Interview Questions with Answers
6. Scenario Based Production Q & A
Telegram channel
===============
telegram.me/ab...
GitHub Repo for Multi Stage Builds
==============================
github.com/iam...
More Distroless Images (Java, Python e.t.c.,.)
=============================================
github.com/Goo...
About me:
================
LinkedIn: / abhishek-veeramalla-77...
GitHub: github.com/iam...
Medium: / abhishekveeramalla-av
UA-cam: / @abhishekveeramalla .
.
Disclaimer: Unauthorized copying, reproduction, or distribution of this video content, in whole or in part, is strictly prohibited. Any attempt to upload, share, or use this content for commercial or non-commercial purposes without explicit permission from the owner will be subject to legal action. All rights reserved.
GOAT greatest of all teachesr. kinda addicted to your page/voice. Thank you is the leas ti can say
There is a movie from South named Vaathi, I'm not sure if you watched it but when I watched Dhanush in it felt as if it's you helping every student and motivating everyone
Means alot brother ❤️
Bro I have around 7 years experience in docker and k8. Dude this was mind blowing content. You nailed it!
You mean the way he explained (I agree 100%), or do you mean that this is a new concept to you, in which case I wonder why this is not being used in production If this is so good as claimed in this video there must be some catch right?
Learning new things daily is actually helping us to be better version of us. Thank you Abhishek :)
Awesome. Please share the videos with your friends
I think it was like 86MB as you are saying it will reduce 100 times after seeing 1.83MB the real purpose of docker is somewhat understand to me . Thank you Abhishek sir😊
🚀🚀
Hi Abhishek,
As an aspiring DevOps Engineer, I learnt most of the tools in DevOps along with strong Linux and little AWS exposure
But still I am not confident enough to go for interviews, as I don't have any hands on experience
If possible could you please make a portal/webpage and assign the jobs (categorise the job as easy, medium and tough) for us
So that we can practice and upgrade ourself.
Thanks in advance
Same here
I will eventually travel to US or UK or wherever you are to thank you personally for your charitable work.
🙏🙏🙏
Thanks alot, You filled the gaps in this topic, where should we use n-number of stages in muti-stage docker file (Explaine one secnario to get overview) no need practicals. thanks in advance.
Awesome
just wow , no words....ah kurchi madatha betti...................................subject vachestadi..🥰
Haha
Once again my favorite teacher has delivered a great training!
Awesome. Please share the videos with your friends
Hi Abhishek, Great videos, I am going through them multiple times. Big fan of your work. :-)
I just had one query here, what was the use of defining alias for base image ? before multistage you have not created alias for base image in Dockerfile.
Yeah .. sometimes the imagename can be very big .. so to avoid typos or overhead of referencing using big image names .. u can just use the alias.
No problem even if you don't use it but if you use it your life becomes easy.
I'm feeling ur god for all devops engineers❤
What a explanation very clear 💥💥 i have gone through other videos bt from this simple n clear explanation i understood the concept of multistage docker...thank u so much for sharing the great teaching 🙏✌️👍
Glad to hear that
Hi Abhishek,
a big shout out to you for your contributions into DevOps , in this video you used GO language to create a multistage docker file, but I didnt fully understand this, it would be better if you can create similar file in python.
Thanks
Hi Abhishek, First of all thanks a lot of putting in lot of effort to bring this course to us.
I have a php application running in docker container. basically does not need any artifacts to be built and only I need to copy the source code to my container. Can I decrease the image size using distroless or any suggestions how to use multi stage builds. My image size is 2.5GB and my source code size is 800MB
Man you are Amazing!!! The way you explain concepts is marvolus. More power to you!!!
writing and remembering binaries looks like a tough job because we cant remember all the binaries! So while writing Dockerfiles should we memorise it or just search it on the internet? Please reply🙏
You explain each & every concept so simply. I'm wondering how you learnt & memorized all this.
Hoping for a quick tip to memorize.
Thank you bhai
Do we need to connect ec2 instance always to git bash to perform any operation on dockers.....?
This is one of the best lessons in the course
even paid courses dont teach the concept of multistage docker builds .
Hats off sir !!
btw i reduced my web application image from 1.3gb to 130mb thanks to this !!!!!
Thats so cool
@@AbhishekVeeramallainstead of using from Ubuntu and all can't we start from distroless image like From scratch ... ???
During build process 1st half of docker will do the things and during execution part 2nd half will work ? Right
Hi Abhishek, great applause to you, really you made devops learning much easier, thanks for that.
I have little observation in this video, You said that the size is reduced by 800% but the sizes are same for both.
Please check it once , If I am wrong sorry in advance.
Please recheck image size is reduced
This is very very new thing. Performance tuning along with minimalizing the potential security threat as well.
I tried with my python application:
Without Multi Stage: 904 MB
With Multi Stage: 54 MB
Awesome
this was best video on multi stage build !! plz make a video containerizing full stack web app with multi stage
Hats off to you Abhishek, so clearly u have explained ,simply Superbbbbbb. :)
Thank you so much 😀
Great One, Understood really well. Thanks Abhishek.
Most welcome!
Hi Abhishek Bro,
I am getting returned a non-zero code: 100 when trying to build the docker image for dockerfile-without-multistage. Please help to suggest. I am new to docker FYI
At 24.46 i got an error
Error: failed to solver: process "/bin/sh -c apt get update"
didnot complete successfully: exit code : 100
I tried many steps but didnt help!
somebody who went through this know what went wrong pls let me know
Hi Abhishek, the demo was very nice. I tried to run the application from the mutistage container to understand it actually runs. So, I ran the command "docker exec -it multistage bash"
and it ran the application. I hope this is the way to test that it is actually working in the multistage container without the base image requirements. Please comment. Thanks
Hi if we are taking java distroless images then that is having minimal linux and openjdk runtime, will that not be sufficient to execute an application?
After taking the distroless image in stage 2 why we need stage 1 binary files? Could you please help on this question
Sir i have this doubt from many of your videos, for ex: in this video at 21.52min, you shared your iterm terminal.
Please correct me if iam wrong! You didn't ssh to any EC2 but you cloned git on your terminal because mac terminal comes with default git and shell commands.
But i do all practicals, with ssh to EC2 ubuntu from my command prompt. Now how should i do the practical for this video? For the same reason im unable to complete my day-17 terraform practical as well..
Please help me here....!!
Yes I am on mac 🖥️ .. so I can run the shell commands by default .. if you are on windows.. ssh to ec2 instance and follow the video on your ec2
Final stage creates minimalist image.
Distroless image is very minimalistic image that will hardly have any packages.
Python distroless image will only have python runtime, openjdk etc
Golang distroless image will not even have runtime. Golang has statically typed application.
Advantages of distroless image is super lightweight minimalistic size and highest level of security since it's not exposed to os level vulnerabilities.
You are preparing the video notes in comments 😀
Abhishek anna, one request, please make videos on k8s as simpler as possible, its getting very difficult to understand from others, and also after finishing k8s , make a interview related video of k8s, please its a request , thank you
Sure
@@AbhishekVeeramalla thank you so much anna
Your content are awesom from interview purpose especially..superb bro
Thank you so much 😀
sometimes, container will just run the script and exit, why do we face such issues and how to overcome ? what is the reason behind that ? Could please explain, it is a request ?
Due to that i am losing my confidence of building own docker images.
If you are using -rm argument in the docker command , it deletes the container once the job is done
theoretical explanation lo yenta smooth ga cheputhroo pratical ga chepettappudu yendhuku hadavidiga chebutaroo ..... but i m learning new topics about devops thankyou abhishek
Thanks for the feedback Mamatha .. I will try to improve and teach slow in practical as well
@@AbhishekVeeramalla i m sry, i m not able to catch u r points .... but others may understanding well ... its al abt my point of view i shared ...
I appreciate your feedback.. no problem at all
Abhishek right now I am learning a devops course and they said complete course in mobaxterm and when I watch your videos in Ubuntu I am unable to understand brother .. please tell me that in real time what will be using .. I hope you clarify
I can clearly see the image size reduced to far lesser size than earlier. thank you.
😍
26:54 What is the purpose of this command in docker file can anyone explain ? COPY . .
sir ....how to write docker file
you dont tell us about docker file ...is it not very important for us
the image size is getting reduced drastically while using multistage build,, does the application works properly ..?? after reducing the size..
Application should run as usual
గ్రేట్ వీడియోస్ ఫ్రమ్ అభిషేక్.
క్లౌడ్ విత్ రాజ్ వీడియోస్ లో వాడిన ఎక్సప్లనేషన్ తో ( పిక్చర్ ఎక్సప్లనేషన్)ఇంకా బాగా అర్థమవుతుంది.
Bro cloud related job ki Aws, Linux , one programming language enough aa bro
Chat gpt can effect devops Engineer future ?? Please answer this question
I also wish to know this answer !!
Already made a video on the channel , please check
@@AbhishekVeeramalla ok sure
I liked the tech info you are showing with good understanding of them... its awesome... I feel so when I can become like you... thank you
All the best
Well explained with real life examples. Welldone Abishek
What is FROM image_name -slim. iHave seen a youtube using slim to reduce the size.
Its just an image name .. for example , debian offers debian-slim, which is small compared to traditional images
seems like go application size reduces to 1.8mb and java application is 200mb. what about nodejs build size?
somewhere close to 200 MB
thanks so much for the clarity ....abhishek you mentioned about database image in the layer but what significance does database have while we are building the image
If you would like to containerize your db, you need to create another dockerfile for db
How to call 2 different builds in final stage.
Stage 1 with golang
Stage2 with Java runtime
Final stage :
copy --from= build1, build2
Please suggest. Thank you
Yes u can do that ..
Just write two statements
copy - from
copy -from
@@AbhishekVeeramalla thank you
a GURU ....🙏
but sir how to write docker files....
Explaining very well bro, thanks for all your content. I have one question, can we have the distroless images for windows .Net framework 4.8 web application
answer from microsoft forums >> We currently do not supply Windows-based container images.
what a size reduce, awesome Abhishek... thank you for this tremendous video
My pleasure 😊
@@AbhishekVeeramalla I trying with CentOS machine
But with CentOS machine I am not able to do such thing..
But with Ubuntu machine it works awesome..
Hi Abhishek,
Thankyou for sharing your knowledge
Can you please explain why do we use withpythonenv
withpythonenv(‘python3’) {
sh ‘’’
Pip3 install -upgrade pip wheel setuptools
Pip3 install -r pd-deploy/requirements.txt
‘’’
Is it for virtual env ?
Hi abhishek, as I follow along to complete the build , My build stops at step 5/8 when using the RUN CGO_ENABLED phase. Any suggestions? Great video by the way first time hearing about multi stage and distroless concept and you explained it perfectly.
Is it safe to use distroless image in Production environment ?
Hi sir, When you say guess the image size, I think this might be goes around 100MB but it 1.84MB. Your dedication was out of the world. Thanks for providing this wonderful session.
Hi @Abhishel.Veeramalla,
Whil creating code pipeline, ECR is source and ECS is Deploy selected, but deploy stage is failing with in artfact bucket imagedefinition file is not valid json, how to deploy ECR images to ECS automatically? any session on this automation, please assist
Why to build the application in Dockerfile itself ??? We can build applications in local or any CI server then we can use those built artifacts in Dockerfile directly right ??? By this also we can have light weight dockerimage ....
Hi .. but that is manual activity and not automation. Let's say .. there is a change in the application code .. would you build everything again manually ?
@@AbhishekVeeramalla Yeah I agree, if we build it in local. But In my project, we are building the applications with jenkins CI server and then using artifacts to create a minimalstic docker image. By this we can save some networking charges too right ?? As cloud providers will charge for internet traffic too by avoiding multiple times updating the packages and installing required packages to base image.
Overall, distroless images are particularly advantageous for production environments where security, performance, and efficiency are critical.
I have requirement to install multiple softwares like python, node, aws, serverless, Java etc. Can i use multistage in this case? Now my image size is very very huge
Why do u need so many ? Please recheck the architecture of your application
@@AbhishekVeeramalla Thanks for the quick reply..
My requirement is to install all the required package in a single docker image, where the image can be used in my CI/CD through Kubernetees. So, i have to make the docker image ready with all softwares
I Built simple calculator-multistage with that another built also showing when you enter docker images comand. 2 images built at a time. (timestamp is 29.45)
yes we can decrease image size by docker builds using alpine images or distroless images but the application need to work as per the expectations after reducing size to 1.8mb is application working as per expected?
I'm guessing 8 Mb....still watching though...
Can anyone explain the process from 22:50 plz
Hello Abhishek, thanks for the playlist of learning Docker. Please can you re-arrang the playlist to have them in order?
13:30 anna this time you said that we can run the application with the help of artifact that is generated in stage but when you are installing the dependencies in first stage you included the MySQL also but what are the dependencies that we install for MySQL? The database is in the seperate container and we communicate with the db using network so need to install the MySQL dependencies in the stage 1 i think. I am a beginner just correct me if I am wrong 🙏
Honestly I don't know about these dependencies 😅 because we are using PHP
Docker ke ela telustumde manam multi stage lo code rasamu ani
When there are multiple FROM statements in the Dockerfile
Awesome content and explanation @Abhishek .thanks a lot . Can you please suggest or help me more to understand Dockerfile as i am a beginner so commands are hard for me .I need more explanation in detail .Please let me know your note on same. thanks a lot .
Hi bhaiya, from where I can practice creating docker file so that I can get understanding of it. I am new to docker. Please suggest.
The explanation is very good but I have a query at 28-29 mins. After you build the multi stage image, it is showing an old image too, so my query is whether it depends on the old one?
Hii anna,
Could you please make a video on multi stage on three tier application
Noted .. will try
Abhishek you keep giving us good stuff. Thank you so much ❤
My pleasure 😊
very happy to learn new advanced topics with your simple way of explanations. Thank You Abhishek
Hi, can you explain a bit more abt the source code and the binary , how do we write them . Thank you !!
As a devops engineer you don’t write that. Because I have a development background, I was able to write
Very well explained Abhishek bhai..keep doing the good work.!!
Thanks a lot
This is very helpful, totally enjoyed this session and learned a lot, thanks Abhishek
you said you would talk about docker commands in this video but you didnt cover is it there in next video?
Awesome explanation. Learnt many new things.
Hi Abhishek , do we need to have google cloud sdk / cli in our ec2 instance ,to download any distroless images? if it is, how it will be sync with docker hub. please suggest.
Hi Abhishek , it’s a great thing to share knowledge for free, people like you are very less now a days
Appreciated a lot
I have a doubt on multistage while creating image it will fetch from the last Entry point from the bottom right ? Correct me if am wrong and second thins if we push this image and some one else pulled to their local , can they perform same without downloading the golang dependencies
Great vdo on optimising docker images. I have fear of working on this. But now I got the confidence
Can I apply for job with only docker and kubernetes knowledge?
You are giving good knowledge for us, we appreciate your efforts. Plan a day to meet us at one place, it will be a chance to say thank you...
Awesome. Please share the videos with your friends
I am already shared bro. You are giving best knowledge
Damn bro I was here to learn docker now my mind is blown😮
thank you thank you thnk you thank you....thank you v.much sir.
May you stay blessed and happy always.
Clear and concise explanation anybody can understand, brilliant!! Great content 👍
Thanks Sunil
Sir I have a question please kindly reply 🙏, if we are building a application do we really need a container to run that? For example, in a Jenkins pipeline we first build then test and last create a docker image out of it , but in a go application when I am doing "go build" its providing me a direct executable which can be directly run on ec2 ( using ./myapp) So in these scenario do we really need to build a docker image ? Can't we just simply put the executable directly on the ec2? And same thing goes for a nodejs application when I am using pkg to create an executable
We can't, because ec2 does not have dependencies installed . So build the application jar file with dependencies and run application inside the docker container. No need to run application on ec2
To run an application I don't need a source code, packages. Only artifact binary is required, that can very well run using distroless minimalistic image.
For golang, scratch is distroless minimalist image।
You are preparing the notes in comments 😀
Amazing.. Abhishek.. Good
Keep it up. Liked it
Thanks
Whoa!!! much smaller! Great tutorial - new follower!
what is scratch? What is binary?
Wonderful explanation Abhishek. You rock
Thanks alot
Abhishek, can you please make a video on docker compose?
anna networking playlist hide chesara
Ledu em hide cheyale
Can you please cover maven, sonarqube and artifactory tools.
Please watch video named ultimate cicd pipeline.. everything covered
@@AbhishekVeeramalla Ok thanks a lot 😊
Can you make video to guild about microservice pls
Abhi anna big fan of your explanation and voice
Thanks alot
thsi helped.
super abhishek am started learning from your videos its very nice teaching to the world and thank you.
What is the advantage if we join in your channel