Skip to main content
# whale-linter

[![PyPI](https://img.shields.io/pypi/v/whalelinter.svg)](https://pypi.python.org/pypi/whalelinter)
[![PyPI](https://img.shields.io/pypi/dm/whalelinter.svg)](https://pypi.python.org/pypi/whalelinter)
[![PyPI](https://img.shields.io/pypi/l/whalelinter.svg)](https://raw.githubusercontent.com/jeromepin/whale-linter/master/LICENSE)
[![Docker Stars](https://img.shields.io/docker/stars/jeromepin/whale-linter.svg)](https://hub.docker.com/r/jeromepin/whale-linter/)
[![Docker Pulls](https://img.shields.io/docker/pulls/jeromepin/whale-linter.svg)](https://hub.docker.com/r/jeromepin/whale-linter/)

**whale-linter** is a cross-platform *Dockerfile* linter.

![alt text](https://raw.githubusercontent.com/jeromepin/whale-linter/master/whale-linter.png)


## Installation

#### Tested on

* Python 3.2, 3.4, 3.5
* Debian wheezy, jessie, stretch


### Docker : The cool way :)

**Note** : You should use a specific tag (like `jeromepin/whale-linter:0.0.3`) instead of (implicit) *latest*

```
docker run -it --rm -v /path/to/Dockerfile:/Dockerfile jeromepin/whale-linter
```


### PyPI : The easy way

```bash
pip install whalelinter
```

and to upgrade :

```bash
pip install --upgrade whalelinter
```


## Usage

```bash
usage: whale-linter [-h] [-i RULE] [-v] DOCKERFILE

A simple non professional Dockerfile linter

positional arguments:
DOCKERFILE The Dockerfile to lint

optional arguments:
-h, --help Show this help message and exit
-i, --ignore RULE Rule to ignore
-v, --version Print version
```


## Rules

Here is the list of all rules checked by **whale-linter**.

Do not hesitate to [create a new issue](https://github.com/jeromepin/whale-linter/issues/new) if you have an idea for a new/incomplete rule.


Rules are ordered as follows :

* *WL1xxx* : Critical errors

* *WL2xxx* : Bad practices

* *WL3xxx* : Enhancements


| Rule | Corresponding message (as template given in config.json) |
| ------ | ----------- |
| [WL1000](https://github.com/jeromepin/whale-linter/wiki/WL1000) | '{token}' is mandatory |
| [WL1001](https://github.com/jeromepin/whale-linter/wiki/WL1001) | '{token}' must be present only once |
| [WL2000](https://github.com/jeromepin/whale-linter/wiki/WL2000) | A tag should be specified for the '{image}' image |
| [WL2001](https://github.com/jeromepin/whale-linter/wiki/WL2001) | Using the 'latest' tag isn't wise, as it won't always be a reference to the same version |
| [WL2002](https://github.com/jeromepin/whale-linter/wiki/WL2002) | Use 'WORKDIR' to change directory |
| [WL2003](https://github.com/jeromepin/whale-linter/wiki/WL2003) | Some shell commands like '{command}' are pointless in containers |
| [WL2004](https://github.com/jeromepin/whale-linter/wiki/WL2004) | 'WORKDIR' path should be absolute |
| [WL2005](https://github.com/jeromepin/whale-linter/wiki/WL2005) | 'EXPOSE' port ({port}) must be in 1-65535 range |
| [WL2006](https://github.com/jeromepin/whale-linter/wiki/WL2006) | Prefer 'COPY' over 'ADD' for adding files and directories to a container. 'ADD' sounds to much magic |
| [WL2007](https://github.com/jeromepin/whale-linter/wiki/WL2007) | Be careful changing to root user |
| [WL2008](https://github.com/jeromepin/whale-linter/wiki/WL2008) | Avoid running 'apt-get upgrade' in container. Move to a newer image instead |
| [WL2009](https://github.com/jeromepin/whale-linter/wiki/WL2009) | Missing '--no-install-recommends' in your '{command}' command |
| [WL2010](https://github.com/jeromepin/whale-linter/wiki/WL2010) | Missing '-y' in your '{command}' command |
| [WL2011](https://github.com/jeromepin/whale-linter/wiki/WL2011) | Avoid running 'apt-get dist-upgrade' in container. Move to a newer image instead |
| [WL2012](https://github.com/jeromepin/whale-linter/wiki/WL2012) | There is two consecutive 'RUN'. Consider chaining them with '\' and '&&' |
| [WL3000](https://github.com/jeromepin/whale-linter/wiki/WL3000) | Consider removing APT cache : 'rm -rf /var/lib/apt/lists/*' |
| [WL3001](https://github.com/jeromepin/whale-linter/wiki/WL3001) | Using '{token}' is recommended |
| [WL3002](https://github.com/jeromepin/whale-linter/wiki/WL3002) | Consider sorting APT packages for better reading |
| [WL3003](https://github.com/jeromepin/whale-linter/wiki/WL3003) | A version should be specified for the package '{package}' in order to improve immutability |


## Author

Jerome Pin ([@jerome_pin](https://twitter.com/jerome_pin)) <<jerome@jeromepin.fr>>


## Licence

MIT. See [LICENCE](https://raw.githubusercontent.com/jeromepin/whale-linter/master/LICENSE) file.

Metadata

Release files for whale-linter 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whale-linter 0.0.4
File Size Uploaded
whale-linter-0.0.4.tar.gz 9.9 kB Details

Release files / whale-linter-0.0.4.tar.gz

Download URL whale-linter-0.0.4.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
eafc7936518f019e43b6e2210c61e45ff2c62bd32ebf4dfdc1cc2f380ce2969f
BLAKE2b-256 checksum
How to use checksums
7e377187794fb0b8c01dcac031aadf573534121f4d011d00a712bab874240b10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

This release

0.0.4 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page