<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>dokerfile | 伪架构师</title>
    <link>/tags/dokerfile/</link>
      <atom:link href="/tags/dokerfile/index.xml" rel="self" type="application/rss+xml" />
    <description>dokerfile</description>
    <generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>zh</language><lastBuildDate>Sun, 12 Jan 2020 22:12:50 +0800</lastBuildDate>
    <image>
      <url>/img/logo-wide.png</url>
      <title>dokerfile</title>
      <link>/tags/dokerfile/</link>
    </image>
    
    <item>
      <title>一个小工具：Hadolint</title>
      <link>/post/intro-hadolint/</link>
      <pubDate>Sun, 12 Jan 2020 22:12:50 +0800</pubDate>
      <guid>/post/intro-hadolint/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/hadolint/hadolint&#34; target=&#34;_blank&#34;&gt;Hadolint&lt;/a&gt; 是使用不明觉厉的 Haskell 实现的 Dockerfile linter，其实现依据来自于 Docker 官网推荐的 &lt;a href=&#34;https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices&#34; target=&#34;_blank&#34;&gt;Dockerfile 最佳实践&lt;/a&gt;。&lt;/p&gt;

&lt;p&gt;在 Mac 下的安装只要使用简单的 &lt;code&gt;brew install hadolint&lt;/code&gt; 就能够完成安装，其它平台也有各自的支持方式。&lt;/p&gt;

&lt;p&gt;用法非常简单：&lt;code&gt;hadolint &amp;lt;dockerfile&amp;gt;&lt;/code&gt; 即可，例如我们编写一个简单的 Dockerfile：&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-shell&#34;&gt;$ cat &amp;lt;&amp;lt; EOF &amp;gt; /tmp/Dockerfile                                                                             master  ✱
heredoc&amp;gt; FROM alpine
heredoc&amp;gt; CMD [&amp;quot;sleep&amp;quot;, &amp;quot;3600&amp;quot;]
heredoc&amp;gt; EOF

$ hadolint /tmp/Dockerfile
/tmp/Dockerfile:1 DL3006 Always tag the version of an image explicitly
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;可以使用 &lt;code&gt;--ignore&lt;/code&gt; 参数忽略指定的问题，如果是固定配置，可以使用 &lt;code&gt;-c&lt;/code&gt; 参数指定配置文件。例如下面的配置：&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-yaml&#34;&gt;ignored:
  - DL3000
  - SC1010

trustedRegistries:
  - docker.io
  - my-company.com:5000
&lt;/code&gt;&lt;/pre&gt;

&lt;blockquote&gt;
&lt;p&gt;其检测范围包括在 &lt;a href=&#34;https://github.com/hadolint/hadolint/blob/master/README.md&#34; target=&#34;_blank&#34;&gt;README&lt;/a&gt; 有非常详细的描述，并在连接中给出了建议。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;hadolint 提供了很多&lt;a href=&#34;https://github.com/hadolint/hadolint/blob/master/docs/INTEGRATION.md&#34; target=&#34;_blank&#34;&gt;集成选项&lt;/a&gt;，可以集成到 Jenkins、Gitlab 等自动化流程中使用，在 vim、VSCode、Atom 编辑器中也可以直接生效。&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;README：&lt;code&gt;https://github.com/hadolint/hadolint/blob/master/README.md&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;集成选项：&lt;code&gt;https://github.com/hadolint/hadolint/blob/master/docs/INTEGRATION.md&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
  </channel>
</rss>
