<?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: Shriraj Shakunt</title>
    <description>The latest articles on DEV Community by Shriraj Shakunt (@shakunt).</description>
    <link>https://dev.to/shakunt</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%2F845050%2Fe8d19818-253c-4ce3-bf36-dd7ffce3192d.jpeg</url>
      <title>DEV Community: Shriraj Shakunt</title>
      <link>https://dev.to/shakunt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shakunt"/>
    <language>en</language>
    <item>
      <title>Docker Content Trust (DCT)</title>
      <dc:creator>Shriraj Shakunt</dc:creator>
      <pubDate>Sat, 21 May 2022 08:23:15 +0000</pubDate>
      <link>https://dev.to/shakunt/docker-content-trust-dct-5fhp</link>
      <guid>https://dev.to/shakunt/docker-content-trust-dct-5fhp</guid>
      <description>&lt;p&gt;Docker Content Trust (DCT) provides the ability to use digital signatures for data sent to and received from remote Docker registries. These signatures allow client-side or runtime verification of the integrity and publisher of specific image tags.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Latest Docker desktop &lt;/li&gt;
&lt;li&gt;Docker hub account&lt;/li&gt;
&lt;li&gt;Docker contrainer image
## Documentation
Refer the DCT 
&lt;a href="https://docs.docker.com/engine/security/trust/"&gt;Documentation&lt;/a&gt;
here&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Deployment
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Make a docker repository for your images
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="https://hub.docker.com/"&gt;Docker Hub&lt;/a&gt; and sign in with your docker hub account&lt;/li&gt;
&lt;li&gt;Click on Create repository and name it "test"&lt;/li&gt;
&lt;li&gt;It should look something like this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ocaMTVDT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/67914403/169215095-bc4f50ca-73cf-4909-b5e5-b5906d8765e2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ocaMTVDT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/67914403/169215095-bc4f50ca-73cf-4909-b5e5-b5906d8765e2.png" alt="docker create repo" width="880" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Do Docker login in your CLI with
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Enter your credentials and you are ready to go.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  To Sign a docker image we have first generate a key...
&lt;/h3&gt;

&lt;p&gt;To generate a key run this command in your CLI&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  docker trust key generate signature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This "Signature" is the name you will give to your key and it will be saved in your working directory with the .pub extension&lt;/li&gt;
&lt;li&gt;After running this command you will be asked to enter and repeat a passphrase.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To make a signer and add it to your repository run this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker trust signer add &lt;span class="nt"&gt;--key&lt;/span&gt; signature.pub &lt;span class="o"&gt;[&lt;/span&gt;signer&lt;span class="s1"&gt;'s name] [your repository'&lt;/span&gt;s name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The repository name will be something like this --&amp;gt; example/test&lt;/li&gt;
&lt;li&gt;You have to enter and repeat passphrase for root key and repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Signing and Pushing images to the repository
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;First let's commit our container image.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker commit &lt;span class="o"&gt;[&lt;/span&gt;Image ID] &lt;span class="o"&gt;[&lt;/span&gt;Repository Name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You can find the image ID from
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Let's push an unsigned image for reference
-First tag the image as unsigned-image
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker image tag &lt;span class="o"&gt;[&lt;/span&gt;Image ID] &lt;span class="o"&gt;[&lt;/span&gt;Repository Name]:unsigned-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now push the image with
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker push &lt;span class="o"&gt;[&lt;/span&gt;Repository Name]:unsigned-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now sign the tag and sign the same image.
Tag the image with
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker image tag &lt;span class="o"&gt;[&lt;/span&gt;Image ID] &lt;span class="o"&gt;[&lt;/span&gt;Repository Name]:signed-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sign the image with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker trust sign &lt;span class="o"&gt;[&lt;/span&gt;Repository Name]:signed-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You have to again enter the passphrase&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the the further imformation about the signed image run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker trust inspect &lt;span class="nt"&gt;--pretty&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;Repository Name]:signed-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Push the signed image with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker push &lt;span class="o"&gt;[&lt;/span&gt;Repository Name]:signed-image

The push refers to repository &lt;span class="o"&gt;[&lt;/span&gt;docker.io/shakunt/test]
059ff50d778b: Layer already exists
c4e64d78638e: Layer already exists
5f70bf18a086: Layer already exists
0cd0f4e90e0c: Layer already exists
e4a7f8c5002b: Layer already exists
7cc0623bd7a8: Layer already exists
f1859b30ca6b: Layer already exists
6a35d52a66fd: Layer already exists
fbd7d5451c69: Layer already exists
4fc242d58285: Layer already exists
trust-image-signed: digest: sha256:f6274d55e7ae079737180c7cb5----7387fb6a87297ef486edbc1bb16f4d0 size: 2409
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Setting up trust environment and pulling the signed and unsigned images
&lt;/h3&gt;

&lt;p&gt;To set up the trust environment run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;DOCKER_CONTENT_TRUST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's pull the images&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;unsigned image
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker pull &lt;span class="o"&gt;[&lt;/span&gt;Repository Name]:unsigned-image
No valid trust data &lt;span class="k"&gt;for &lt;/span&gt;unsigned-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Signed image
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker pull &lt;span class="o"&gt;[&lt;/span&gt;Repository Name]:signed-image
Pull &lt;span class="o"&gt;(&lt;/span&gt;1 of 1&lt;span class="o"&gt;)&lt;/span&gt;: shakunt/test:signed-image@sha256:f6274d55e7ae079737180c7cb5b02f386edbc1bb16f4d0
docker.io/shakunt/test@sha256:f6274d55e7ae079737180c7cb5b02f3767387fb6a87bb16f4d0: Pulling from shakunt/test
Digest: sha256:f6274d55e7ae079737180c77fb6a87297ef486edbc1bb16f4d0
Status: Image is up to &lt;span class="nb"&gt;date &lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;shakunt/test@sha256:f6274d551bb16f4d0
Tagging shakunt/test@sha256:f6274d55e7ae079732f3767387fb6a87297ef486edbc1bb16f4d0 as shakunt/test:signed-image
docker.io/shakunt/test:signed-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thank u, Hope this post helped you!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.instagram.com/shakunt_r_a_j/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mSNCM1BT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/Instagram-%2523E4405F.svg%3Flogo%3DInstagram%26logoColor%3Dwhite" alt="Instagram" width="85" height="20"&gt;&lt;/a&gt; &lt;a href="https://www.linkedin.com/in/shakunt-raj-5a71a71b5/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PlM2DF7u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/LinkedIn-%25230077B5.svg%3Flogo%3Dlinkedin%26logoColor%3Dwhite" alt="LinkedIn" width="75" height="20"&gt;&lt;/a&gt; &lt;a href="https://twitter.com/JShakunt/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RDXjor_X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/Twitter-%25231DA1F2.svg%3Flogo%3DTwitter%26logoColor%3Dwhite" alt="Twitter" width="67" height="20"&gt;&lt;/a&gt; &lt;br&gt;
&lt;a href="https://dev.to/shakunt"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QUS05h8i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/dev.to-0A0A0A%3Flogo%3Ddev.to%26logoColor%3Dwhite" alt="Dev to" width="63" height="20"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="mailto:shakunt1202@gmail.com"&gt;&lt;br&gt;
 &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xbsswz-Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/Gmail-D14836%3Flogo%3Dgmail%26logoColor%3Dwhite" width="59" height="20"&gt;&lt;/a&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
