|
| 1 | +# https://github.com/projectatomic/dockerfile_lint |
| 2 | +--- |
| 3 | + profile: |
| 4 | + name: "Default" |
| 5 | + description: "Default Profile. Checks basic syntax." |
| 6 | + line_rules: |
| 7 | + LABEL: |
| 8 | + paramSyntaxRegex: /.+/ |
| 9 | + defined_namevals: |
| 10 | + Name: |
| 11 | + valueRegex: /[\w]+/ |
| 12 | + message: "Label 'name' is missing or has invalid format" |
| 13 | + level: "error" |
| 14 | + required: true |
| 15 | + Version: |
| 16 | + valueRegex: /[\w.${}()"'\\\/~<>\-?\%:]+/ |
| 17 | + message: "Label 'version' is missing or has invalid format" |
| 18 | + level: "error" |
| 19 | + required: true |
| 20 | + Maintainer: |
| 21 | + valueRegex: /[\w]+/ |
| 22 | + message: "Label 'maintainer' is missing or has invalid format" |
| 23 | + level: "error" |
| 24 | + required: true |
| 25 | + |
| 26 | + FROM: |
| 27 | + paramSyntaxRegex: /^[\w./\-:]+(:[\w.]+)?(-[\w]+)?( as \w+)?$/i |
| 28 | + rules: |
| 29 | + - |
| 30 | + label: "is_latest_tag" |
| 31 | + regex: /latest/ |
| 32 | + level: "error" |
| 33 | + message: "base image uses 'latest' tag" |
| 34 | + description: "using the 'latest' tag may cause unpredictable builds. It is recommended that a specific tag is used in the FROM line or *-released which is the latest supported release." |
| 35 | + reference_url: |
| 36 | + - "https://docs.docker.com/engine/reference/builder/" |
| 37 | + - "#from" |
| 38 | + - |
| 39 | + label: "no_tag" |
| 40 | + regex: /^[:]/ |
| 41 | + level: "error" |
| 42 | + message: "No tag is used" |
| 43 | + description: "lorem ipsum tar" |
| 44 | + reference_url: |
| 45 | + - "https://docs.docker.com/engine/reference/builder/" |
| 46 | + - "#from" |
| 47 | + RUN: |
| 48 | + paramSyntaxRegex: /.+/ |
| 49 | + rules: |
| 50 | + - |
| 51 | + label: "no_yum_clean_all" |
| 52 | + regex: /yum(?!.+clean all|.+\.repo|-config|\.conf)/g |
| 53 | + level: "warn" |
| 54 | + message: "yum clean all is not used" |
| 55 | + description: "the yum cache will remain in this layer making the layer unnecessarily large" |
| 56 | + reference_url: |
| 57 | + - "http://docs.projectatomic.io/container-best-practices/#" |
| 58 | + - "_clear_packaging_caches_and_temporary_package_downloads" |
| 59 | + - |
| 60 | + label: "yum_update_all" |
| 61 | + regex: /yum(.+update all|.+upgrade|.+update|\.config)/ |
| 62 | + level: "info" |
| 63 | + message: "updating the entire base image may add unnecessary size to the container" |
| 64 | + description: "update the entire base image may add unnecessary size to the container" |
| 65 | + reference_url: |
| 66 | + - "http://docs.projectatomic.io/container-best-practices/#" |
| 67 | + - "_clear_packaging_caches_and_temporary_package_downloads" |
| 68 | + - |
| 69 | + label: "no_dnf_clean_all" |
| 70 | + regex: /dnf(?!.+clean all|.+\.repo)/g |
| 71 | + level: "warn" |
| 72 | + message: "dnf clean all is not used" |
| 73 | + description: "the dnf cache will remain in this layer making the layer unnecessarily large" |
| 74 | + reference_url: |
| 75 | + - "http://docs.projectatomic.io/container-best-practices/#" |
| 76 | + - "_clear_packaging_caches_and_temporary_package_downloads" |
| 77 | + - |
| 78 | + label: "no_rvm_cleanup_all" |
| 79 | + regex: /rvm install(?!.+cleanup all)/g |
| 80 | + level: "warn" |
| 81 | + message: "rvm cleanup is not used" |
| 82 | + description: "the rvm cache will remain in this layer making the layer unnecessarily large" |
| 83 | + reference_url: |
| 84 | + - "http://docs.projectatomic.io/container-best-practices/#" |
| 85 | + - "_clear_packaging_caches_and_temporary_package_downloads" |
| 86 | + - |
| 87 | + label: "no_gem_clean_all" |
| 88 | + regex: /gem install(?!.+cleanup|.+\rvm cleanup all)/g |
| 89 | + level: "warn" |
| 90 | + message: "gem cleanup all is not used" |
| 91 | + description: "the gem cache will remain in this layer making the layer unnecessarily large" |
| 92 | + reference_url: |
| 93 | + - "http://docs.projectatomic.io/container-best-practices/#" |
| 94 | + - "_clear_packaging_caches_and_temporary_package_downloads" |
| 95 | + - |
| 96 | + label: "no_apt-get_clean" |
| 97 | + regex: /apt-get install(?!.+clean)/g |
| 98 | + level: "warn" |
| 99 | + message: "apt-get clean is not used" |
| 100 | + description: "the apt-get cache will remain in this layer making the layer unnecessarily large" |
| 101 | + reference_url: |
| 102 | + - "http://docs.projectatomic.io/container-best-practices/#" |
| 103 | + - "_clear_packaging_caches_and_temporary_package_downloads" |
| 104 | + - |
| 105 | + label: "privileged_run_container" |
| 106 | + regex: /privileged/ |
| 107 | + level: "warn" |
| 108 | + message: "a privileged run container is allowed access to host devices" |
| 109 | + description: "Does this run need to be privileged?" |
| 110 | + reference_url: |
| 111 | + - "http://docs.docker.com/engine/reference/run/#" |
| 112 | + - "runtime-privilege-and-linux-capabilities" |
| 113 | + - |
| 114 | + label: "installing_ssh" |
| 115 | + regex: /openssh-server/ |
| 116 | + level: "warn" |
| 117 | + message: "installing SSH in a container is not recommended" |
| 118 | + description: "Do you really need SSH in this image?" |
| 119 | + reference_url: "https://github.com/jpetazzo/nsenter" |
| 120 | + - |
| 121 | + label: "no_ampersand_usage" |
| 122 | + regex: / ; / |
| 123 | + level: "warn" |
| 124 | + message: "using ; instead of &&" |
| 125 | + description: "RUN do_1 && do_2: The ampersands change the resulting evaluation into do_1 and then do_2 only if do_1 was successful." |
| 126 | + reference_url: |
| 127 | + - "http://docs.projectatomic.io/container-best-practices/#" |
| 128 | + - "#_using_semi_colons_vs_double_ampersands" |
| 129 | + EXPOSE: |
| 130 | + paramSyntaxRegex: /^[\d-\s\w/\\]+$/ |
| 131 | + rules: [] |
| 132 | + ENV: |
| 133 | + paramSyntaxRegex: /.+/ |
| 134 | + rules: [] |
| 135 | + ADD: |
| 136 | + paramSyntaxRegex: /^~?([\w-.~:/?#\[\]\\\/*@!$&'()*+,;=.{}"]+[\s]*)+$/ |
| 137 | + COPY: |
| 138 | + paramSyntaxRegex: /.+/ |
| 139 | + rules: [] |
| 140 | + ENTRYPOINT: |
| 141 | + paramSyntaxRegex: /.+/ |
| 142 | + rules: [] |
| 143 | + VOLUME: |
| 144 | + paramSyntaxRegex: /.+/ |
| 145 | + rules: [] |
| 146 | + USER: |
| 147 | + paramSyntaxRegex: /^[a-z0-9_][a-z0-9_]{0,40}$/ |
| 148 | + rules: [] |
| 149 | + WORKDIR: |
| 150 | + paramSyntaxRegex: /^~?[\w\d-\/.{}$\/:]+[\s]*$/ |
| 151 | + rules: [] |
| 152 | + ONBUILD: |
| 153 | + paramSyntaxRegex: /.+/ |
| 154 | + rules: [] |
| 155 | + required_instructions: |
| 156 | + - |
| 157 | + instruction: "ENTRYPOINT" |
| 158 | + count: 1 |
| 159 | + level: "info" |
| 160 | + message: "There is no 'ENTRYPOINT' instruction" |
| 161 | + description: "None" |
| 162 | + reference_url: |
| 163 | + - "https://docs.docker.com/engine/reference/builder/" |
| 164 | + - "#entrypoint" |
| 165 | + - |
| 166 | + instruction: "CMD" |
| 167 | + count: 1 |
| 168 | + level: "info" |
| 169 | + message: "There is no 'CMD' instruction" |
| 170 | + description: "None" |
| 171 | + reference_url: |
| 172 | + - "https://docs.docker.com/engine/reference/builder/" |
| 173 | + - "#cmd" |
0 commit comments