<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Henrique Santos</title>
    <description>The latest articles on DEV Community by Henrique Santos (@henriquencmt).</description>
    <link>https://dev.to/henriquencmt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1239354%2F13ffdb27-d65d-4418-8da1-d2c5b2820a72.jpeg</url>
      <title>DEV Community: Henrique Santos</title>
      <link>https://dev.to/henriquencmt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/henriquencmt"/>
    <language>en</language>
    <item>
      <title>Distroless images using melange and apko</title>
      <dc:creator>Henrique Santos</dc:creator>
      <pubDate>Fri, 22 Dec 2023 17:16:17 +0000</pubDate>
      <link>https://dev.to/henriquencmt/distroless-images-using-melange-and-apko-2k3i</link>
      <guid>https://dev.to/henriquencmt/distroless-images-using-melange-and-apko-2k3i</guid>
      <description>&lt;p&gt;TL;DR - Beyond &lt;em&gt;size&lt;/em&gt;, which can save time and resources, distroless images* have their &lt;em&gt;complexity&lt;/em&gt; and &lt;em&gt;attack surface&lt;/em&gt; reduced**. In this post, we are going to use &lt;em&gt;melange&lt;/em&gt; and &lt;em&gt;apko,&lt;/em&gt; from Chainguard, to build an apk package with a small Rust program, build an OCI image from it and then load it with Docker.&lt;/p&gt;

&lt;p&gt;* “Distroless” doesn’t mean that the image has no distro at all. The idea is to work with minimal images, so we should bring into it only the essentials for our apps to run, leaving out shells, package managers, etc.&lt;/p&gt;

&lt;p&gt;** &lt;a href="https://www.chainguard.dev/unchained/image-sizes-miss-the-point" rel="noopener noreferrer"&gt;Image sizes miss the point&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;** ”&lt;em&gt;standardization and quality of the software in your direct execution path lowers your attack surface more than distroless does&lt;/em&gt;” - &lt;a href="https://www.redhat.com/en/blog/why-distroless-containers-arent-security-solution-you-think-they-are" rel="noopener noreferrer"&gt;Why distroless containers aren't the security solution you think they are&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;** &lt;a href="https://www.chainguard.dev/unchained/understanding-attacker-techniques-for-distroless-containers" rel="noopener noreferrer"&gt;Understanding attacker techniques in distroless containers&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Table Of Contents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Sample Rust program&lt;/li&gt;
&lt;li&gt;Building apks with melange&lt;/li&gt;
&lt;li&gt;Building OCI images with apko&lt;/li&gt;
&lt;li&gt;Scanning for vulnerabilities&lt;/li&gt;
&lt;li&gt;Source code&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Sample Rust program &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;We are going to build a small Rust program that prints a random value every time we run it.&lt;/p&gt;

&lt;p&gt;Create a new Rust project:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

cargo new random &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;random


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add &lt;code&gt;rand&lt;/code&gt;  crate to your project:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

cargo add rand


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;or manually add this to your &lt;code&gt;Cargo.toml&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;

&lt;span class="nn"&gt;[dependencies]&lt;/span&gt;
&lt;span class="py"&gt;rand&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"0.8.5"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add this code to &lt;code&gt;main.rs&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;

&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Rng&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;rng&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;thread_rng&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u8&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rng&lt;/span&gt;&lt;span class="nf"&gt;.gen&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run it:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

cargo run


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Building apks with melange &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/chainguard-dev/melange" rel="noopener noreferrer"&gt;&lt;strong&gt;melange&lt;/strong&gt;&lt;/a&gt; allows us to build .apk packages (compatible with &lt;a href="https://wiki.alpinelinux.org/wiki/Package_management" rel="noopener noreferrer"&gt;apk&lt;/a&gt;, the package manager used by Alpine Linux distro) using declarative YAML pipelines.&lt;/p&gt;

&lt;p&gt;First, create a file &lt;code&gt;melange.yaml&lt;/code&gt; and add the following instructions to it:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;

&lt;span class="na"&gt;package&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;random&lt;/span&gt;
  &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;0.1.0&lt;/span&gt;
  &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;random number generator&lt;/span&gt;
  &lt;span class="na"&gt;target-architecture&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;all&lt;/span&gt;
  &lt;span class="na"&gt;copyright&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;license&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Apache-2.0&lt;/span&gt;
      &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;*"&lt;/span&gt;

&lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;repositories&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;https://dl-cdn.alpinelinux.org/alpine/edge/main&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;https://dl-cdn.alpinelinux.org/alpine/edge/community&lt;/span&gt;
    &lt;span class="na"&gt;packages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;alpine-baselayout-data&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ca-certificates-bundle&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;busybox&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cargo&lt;/span&gt;

&lt;span class="na"&gt;pipeline&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build Rust application&lt;/span&gt;
    &lt;span class="na"&gt;runs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
      &lt;span class="s"&gt;TARGETDIR="$(mktemp -d)"&lt;/span&gt;
      &lt;span class="s"&gt;cargo build --release --target-dir "${TARGETDIR}"&lt;/span&gt;
      &lt;span class="s"&gt;mkdir -p "${{targets.destdir}}/usr/bin"&lt;/span&gt;
      &lt;span class="s"&gt;mv "${TARGETDIR}/release/random" "${{targets.destdir}}/usr/bin"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://github.com/chainguard-dev/melange/blob/main/docs/BUILD-FILE.md" rel="noopener noreferrer"&gt;You can get more info about these fields here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are going to use two Docker images to generate a temporary keypair and to build the apk package, so we have to pull them:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

docker pull ghcr.io/wolfi-dev/sdk
docker pull cgr.dev/chainguard/sdk


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Generate a temporary keypair to sign your melange packages:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PWD&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;:/work &lt;span class="nt"&gt;--entrypoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;melange &lt;span class="nt"&gt;--workdir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/work ghcr.io/wolfi-dev/sdk keygen


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Build an apk for your host architecture:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;--privileged&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PWD&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;:/work  &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--entrypoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;melange &lt;span class="nt"&gt;--workdir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/work &lt;span class="se"&gt;\&lt;/span&gt;
    cgr.dev/chainguard/sdk build melange.yaml &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--arch&lt;/span&gt; host &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--signing-key&lt;/span&gt; melange.rsa


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;A folder named &lt;code&gt;packages&lt;/code&gt; should be created with the generated apks.&lt;/p&gt;

&lt;p&gt;Now, we can to build an image and install our apk package on it. We’ll do this with apko.&lt;/p&gt;

&lt;h3&gt;
  
  
  Building OCI images with apko &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/chainguard-dev/apko" rel="noopener noreferrer"&gt;apko&lt;/a&gt; allows us to build &lt;a href="https://opencontainers.org/" rel="noopener noreferrer"&gt;OCI container&lt;/a&gt; images from .apk packages.&lt;/p&gt;

&lt;p&gt;Create a file &lt;code&gt;apko.yaml&lt;/code&gt; and add the following content to it:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;

&lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;repositories&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;https://dl-cdn.alpinelinux.org/alpine/edge/main&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/work/packages&lt;/span&gt;
  &lt;span class="na"&gt;packages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;alpine-baselayout-data&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;random&lt;/span&gt;
&lt;span class="na"&gt;accounts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;groups&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;groupname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nonroot&lt;/span&gt;
      &lt;span class="na"&gt;gid&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;65532&lt;/span&gt;
  &lt;span class="na"&gt;users&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nonroot&lt;/span&gt;
      &lt;span class="na"&gt;uid&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;65532&lt;/span&gt;
  &lt;span class="na"&gt;run-as&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;65532&lt;/span&gt;
&lt;span class="na"&gt;entrypoint&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/usr/bin/random&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://github.com/chainguard-dev/apko/blob/main/docs/apko_file.md" rel="noopener noreferrer"&gt;You can get more info about these fields here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Build the image (we are using &lt;a href="http://ghcr.io/wolfi-dev/sdk" rel="noopener noreferrer"&gt;ghcr.io/wolfi-dev/sdk&lt;/a&gt; here):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PWD&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;:/work &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--entrypoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;apko &lt;span class="nt"&gt;--workdir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/work ghcr.io/wolfi-dev/sdk build &lt;span class="nt"&gt;--debug&lt;/span&gt; apko.yaml &lt;span class="se"&gt;\&lt;/span&gt;
     distroless/random random.tar &lt;span class="nt"&gt;-k&lt;/span&gt; melange.rsa.pub &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--arch&lt;/span&gt; host


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run it:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;ARCH_REF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;docker load &amp;lt; random.tar | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Loaded image"&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="s1"&gt;'s/^Loaded image: //'&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-1&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
docker run &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ARCH_REF&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can call &lt;code&gt;echo $ARCH_REF&lt;/code&gt; or &lt;code&gt;docker images&lt;/code&gt; to get your image repository and tag. It should be like this: &lt;code&gt;distroless/random:latest-&amp;lt;host-arch-here&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Scanning for vulnerabilities&lt;/strong&gt; &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Let’s scan our image and see if we detect any vulnerabilities.&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://github.com/docker/scout-cli" rel="noopener noreferrer"&gt;Docker Scout&lt;/a&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

docker scout cves &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ARCH_REF&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo29p6u3wveyz5tyg2vyn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo29p6u3wveyz5tyg2vyn.png" alt="Scan results using Docker Scout"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://aquasecurity.github.io/trivy" rel="noopener noreferrer"&gt;Trivy&lt;/a&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

trivy image &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ARCH_REF&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvjslcpmusqt357mombu6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvjslcpmusqt357mombu6.png" alt="Scan results using Trivy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://github.com/anchore/grype" rel="noopener noreferrer"&gt;Grype&lt;/a&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

grype &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ARCH_REF&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;--scope&lt;/span&gt; all-layers


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F727eivj4r6hq8fuqwstb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F727eivj4r6hq8fuqwstb.png" alt="Scan results using Grype"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Source code&lt;/strong&gt; &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Get the code for this lab here: &lt;a href="https://github.com/henriquencmt/distroless-melange-apko" rel="noopener noreferrer"&gt;https://github.com/henriquencmt/distroless-melange-apko&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;References&lt;/strong&gt; &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.chainguard.dev/unchained/minimal-container-images-towards-a-more-secure-future" rel="noopener noreferrer"&gt;Minimal container images: Towards a more secure future&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/chainguard-dev/hello-melange-apko" rel="noopener noreferrer"&gt;hello-melange-apko&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/chainguard-dev/melange/tree/main/docs" rel="noopener noreferrer"&gt;melange docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/chainguard-dev/apko/tree/main/docs" rel="noopener noreferrer"&gt;apko docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.rust-lang.org/learn/get-started" rel="noopener noreferrer"&gt;Rust&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://crates.io/crates/rand" rel="noopener noreferrer"&gt;rand crate&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>distroless</category>
      <category>docker</category>
      <category>melange</category>
      <category>apko</category>
    </item>
  </channel>
</rss>
