Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT][Dockerfile] Minimize the number of image layers #43

Open
yelghali opened this issue Apr 6, 2023 · 0 comments
Open

[DRAFT][Dockerfile] Minimize the number of image layers #43

yelghali opened this issue Apr 6, 2023 · 0 comments

Comments

@yelghali
Copy link

yelghali commented Apr 6, 2023

Docker images work in the following way – each RUN, COPY, FROM Dockerfile instructions add a new layer & each layer adds to the build execution time & increases the storage requirements of the image.

minimizing the number of layers can significantly reduce image size and container build time.

bad example:
FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install vim -y
RUN apt-get install net-tools -y
RUN apt-get install dnsutils -y
COPY . .

good example:
FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && apt-get upgrade -y && apt-get install --no-install-recommends vim net-tools dnsutils -y

To help you make your container smallers and more optimized, you can use tools like: https://github.com/slimtoolkit/slim

@yelghali yelghali changed the title [DRAFT][Dockerfile] [DRAFT][Dockerfile] Minimize the number of image layers Apr 6, 2023
@jhertout jhertout transferred this issue from green-code-initiative/ecoCode-challenge May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants