How to reduce Docker Image size using Multistage build

Поделиться
HTML-код
  • Опубликовано: 10 ноя 2024

Комментарии • 32

  • @Kyle-Manel
    @Kyle-Manel 11 месяцев назад +1

    THAT SAID, it doesn't appear to alter the required storage on the Docker host, and just hides complexity;
    For instance, what is being done is the production container is drawing from an alterior container, such that, to reproduce the container quickly/easily; Which is a foundational concept of Docker, the build environment requires the full capacity necessary in the first container.
    What this concept appears to produce however, doesn't reduce necessary capacity, but it improves the readability of a container's Dockerfile, compartmentalizing different mechanics within it, & making it more approachable and easier to build from. :-)

    • @sre101
      @sre101  11 месяцев назад +3

      That's very well thought-out. And I agree with most of what you're saying. The biggest benefit I see from Multi-stage is:
      - I run a 30mb Image on my production servers instead of a 1GB image.
      - I run ~5 such images on a server and I have 100s of such servers.
      This reduces my storage costs and network bandwidth costs when my servers download images to run them.
      Debugging a running container is now easier for me, because I have lesser surface area to investigate (minimal OS, only necessary executable file(s), etc).
      But yes, you sacrifice ability to reproduce as you mentioned earlier. Its a trade-off.

  • @akshatsingh02
    @akshatsingh02 11 месяцев назад

    Well explained, here goes one more subscriber for you.

    • @sre101
      @sre101  11 месяцев назад +1

      Means a lot!

  • @MrBharathkumarraju
    @MrBharathkumarraju 9 месяцев назад

    nice thanks for sharing subscribed!!!

    • @sre101
      @sre101  9 месяцев назад

      Thank you 🙌

  • @sivanaikk
    @sivanaikk Год назад

    Amazing, You earned a Subscriber

    • @sre101
      @sre101  Год назад

      Thank you! Feel free to reach out for any feedback and suggestions :)

    • @chetananandlove
      @chetananandlove Год назад

      Same :)

  • @chetananandlove
    @chetananandlove Год назад

    Excellent example

    • @sre101
      @sre101  Год назад

      Thank you Chetan

  • @vignesh3184
    @vignesh3184 Год назад

    Super content🎉 keep rock

    • @sre101
      @sre101  Год назад

      Thanks Vignesh :)

  • @sagarhm2237
    @sagarhm2237 Год назад +1

    can we have some interview series like based based on these content , thanks for it , do one video on multi architecture docker image , becuse when build is done in mac and the infra not suit for production.

    • @sre101
      @sre101  Год назад +1

      Hey thanks for your feedback Sagar.
      I'm currently working on my Docker Series, the first video is already released.
      As part of this, I will also cover docker interviews.
      I'll research more into multi architecture images

    • @sagarhm2237
      @sagarhm2237 Год назад

      @@sre101 bro if it's possible do on monitoring part because most of youtuber will only touch the surface leve for example they will do manual setup of Prometheus as service but in industrial its going to be kube-prometheus stack like students will get strucked.

    • @sre101
      @sre101  Год назад

      @@sagarhm2237 agreed, there's not enough content on monitoring. I will look into it

    • @sagarhm2237
      @sagarhm2237 Год назад

      @@sre101 thanks man seriously needed one of most important to over come lot stress in industries.

  • @julianomoraisbarbosa
    @julianomoraisbarbosa 11 месяцев назад

    Nice job
    Is possible make this sample for php?

    • @sre101
      @sre101  11 месяцев назад

      Thank you Julian. I don't know php myself but if someone else is willing to help me, I could explore that.

  • @iamsmitthakkar
    @iamsmitthakkar Год назад

    Thanks for sharing. How can I reduce a docker image size when my application needs many files.
    For example, a project where there are 100s of sql, some csv files which needs to be bundled into an image. Any idea ?
    I'm not sure what can I

    • @sre101
      @sre101  Год назад

      Ideally don't store all these files in the image.
      If this is data, you should rather be connecting to an external data store to fetch them once your container starts (eg- AWS S3).
      But if you absolutely have to, I think compression is a very good strategy

    • @chetananandlove
      @chetananandlove Год назад

      I guess you can use volume mount , for the same . To reduce the size of actual container

    • @sre101
      @sre101  Год назад

      @@chetananandlove agreed, volumes are also a great option for faster access

  • @adi_malhotra02
    @adi_malhotra02 Год назад

    Are there any caveats to using multi stage builds while running an application in production?

    • @sre101
      @sre101  Год назад

      sometimes you need to install few extra things if you're using a very light base image (like Alpine), so development is slightly harder. But ROI is huge

  • @shaikhrahil6880
    @shaikhrahil6880 Год назад

    U earn a subscriber

    • @sre101
      @sre101  Год назад

      Thanks! Means a lot

  • @cloudnimbus-
    @cloudnimbus- Год назад

    great content, subscribed and liked... please I tried this with a typescript app but the difference isn't much (from 300+MB to 200+MB). do you have any insight to that please...

    • @sre101
      @sre101  Год назад +1

      Great to hear that :)
      This technique is not super effective for interpreted languages such as Typescript or Python.
      Because for interpreted languages, you always need to pack the interpreter and all libraries, codebases in the image - so there's not much to remove.
      One good approach is to consider compiling the code into a standalone executable (eg- Py2exe does this for python)
      Hope this helps!

    • @cloudnimbus-
      @cloudnimbus- Год назад

      Okay, thanks for the response... is there any like py2exe for typescript as well?@@sre101

  • @mallikarjunkonemane6908
    @mallikarjunkonemane6908 Год назад

    🐋🔥🌟