Skip to main content

Distroless Deployments - In Progress

 



“Distroless” images contain only your application and its runtime dependencies. They do not contain package managers, shells or any other programs you would expect to find in a standard Linux distribution.


A distroless image is a slimmed down Linux distribution image plus the application runtime, resulting in the minimum set of binary dependencies required for the application to run.

You don't have Shell in Distroless distribution.

A typical container consists of:

  • Distro base layer - linux distribution files (Ubuntu, CentOS, Debian)
  • Runtime layer (JRE for Java, Python runtime, glibc for C++)
  • Application layer - actual application binaries 

Why should I use distroless images?

w

Distroless images are very small. The smallest distroless image, gcr.io/distroless/static-debian11, is around 2 MiB. That's about 50% of the size of alpine (~5 MiB), and less than 2% of the size of debian (124 MiB).



The general syntax involves adding FROM additional times within your Dockerfile - whichever is the last FROM statement is the final base image. To copy artifacts and outputs from intermediate images use COPY --from=<base_image_number>.


https://github.com/GoogleContainerTools/distroless/blob/main/examples/java/Dockerfile


javac HelloJava.java

jar cfe main.jar HelloJava HelloJava.class

java -jar main.jar



FROM openjdk:11-jdk-slim-bullseye AS build-env

COPY HelloJava.java /app

WORKDIR /app

RUN javac HelloJava.java

RUN jar cfe main.jar HelloJava HelloJava.class


FROM gcr.io/distroless/java11-debian11

COPY --from=build-env /app /app

WORKDIR /app

CMD ["main.jar"]

=====

FROM openjdk:11-jdk-slim-bullseye AS build-env

COPY . /app/examples

WORKDIR /app

RUN javac examples/*.java

RUN jar cfe main.jar examples.HelloJava examples/*.class 


FROM gcr.io/distroless/java11-debian11

COPY --from=build-env /app /app

WORKDIR /app

CMD ["main.jar"]


==================

package examples;


public class HelloJava {

    public static void main(String[] args) {

        System.out.println("Hello world");

    }

}

====================
















Comments

Popular posts from this blog

Lending Cycle in USA. With details on Freddie Mac and Fannie Mae

KEY TERMS Mortgage  A  mortgage loan  is a loan used  to raise funds to buy real estate, or by existing property owners to raise funds for any purpose while putting a  lien  on the property being mortgaged. The loan is " secured " on the borrower's property; t his means that a  legal mechanism  is put into place which allows the lender to take possession and sell the secured property (" foreclosure " or " repossession ") to pay off the loan in the event the borrower defaults on the loan or otherwise fails to abide by its terms. Fungible Fungibility implies that two things are identical in specification, where individual units can be mutually substituted.  Commodities, common shares, options, and dollar bills are examples of fungible goods. Security Refers to a fungible financial instrument.   A security can represent ownership in a corporation in the form of stock, a creditor relationship with a governmental body or a corporation re...

Stock Analysis - Fundamentals

  PB <= 1 A company's price-to-book ratio is the company's current stock price per share divided by its book value per share (BVPS). Dividend Yield (More the better) The dividend yield is a financial ratio that shows how much a company pays out in dividends each year relative to its stock price. PEG Ratio : Lower the better The price/earnings to growth ratio (PEG ratio) is a stock's price-to-earnings (P/E) ratio divided by the growth rate of its earnings Current Ratio: More the better The current ratio, also known as the working capital ratio, measures the capability of a business to meet its short-term obligations that are due within a year. Current Assets / Current Liabilities Quick Ratio: More the better The quick ratio measures the dollar amount of liquid assets available against the dollar amount of current liabilities of a company. The quick ratio provides a more stringent measure of liquidity than the current ratio because it excludes inventory, which ma...

Retirement Corpus - The FIRE Approach

THE FIRE APPROACH FOR RETIREMENT CORPUS Reference Excel Excel Used for the Demonstration