https://github.com/jimschubert/docked
A Dockerfile linting tool
https://github.com/jimschubert/docked
docker go golang linter linting
Last synced: 6 months ago
JSON representation
A Dockerfile linting tool
- Host: GitHub
- URL: https://github.com/jimschubert/docked
- Owner: jimschubert
- Created: 2021-06-19T18:35:10.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-21T22:12:14.000Z (over 2 years ago)
- Last Synced: 2025-03-21T08:35:00.539Z (over 1 year ago)
- Topics: docker, go, golang, linter, linting
- Language: Go
- Homepage: https://pkg.go.dev/github.com/jimschubert/docked
- Size: 1.08 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# docked
A Dockerfile linting tool which aims to pull many best practices and recommendations from multiple sources:
* OWASP
* Docker Official Documentation
* Community recommendations
* Package manager bug trackers
Check out the currently supported [rules](./RULES.md).
[](./LICENSE)

[](https://github.com/jimschubert/docked/actions/workflows/build.yml)

[](https://goreportcard.com/report/github.com/jimschubert/docked)
## tldr;
```
docked analyze ./Dockerfile
```
Successful Outputs:

Failure Outputs:

And, it's customizable. You can ignore, re-prioritize, or add custom rules via regex. There's also JSON and [HTML](https://htmlpreview.github.io/?https://raw.githubusercontent.com/jimschubert/docked/master/.github/examples/html/index.html) outputs.
## Install
### Binaries
Latest binary releases are available via [GitHub Releases](https://github.com/jimschubert/docked/releases).
### Homebrew
```
brew install jimschubert/tap/docked
```
### Docker
```
docker pull jimschubert/docked:latest
```
When running the docker image, be sure to mount and reference the sources appropriately. For example:
### Completions
After you've installed the binary either manually or via Homebrew, consider enabling completions for your shell.
For instructions, view help for your target shell.
#### zsh
```
docked completion zsh --help
```
#### bash
```
docked completion bash --help
```
#### fish
```
docked completion fish --help
```
#### powershell
```
docked completion powershell --help
```
## Usage
```shell
$ docked analyze --help
Analyze a Dockerfile for issues
If not provided, FILE defaults to ./Dockerfile
Usage:
docked analyze [FILE] [flags]
Flags:
-h, --help help for analyze
-i, --ignore strings The lint ids to ignore
-k, --no-buildkit-warnings Whether to suppress Docker parser warnings
--regex-engine string The regex engine to use (regexp, regexp2) (default "regexp2")
--report-type string The type of reporting output (text, json, html) (default "text")
Global Flags:
--config string config file (default is $HOME/.docked.yaml)
--viper use Viper for configuration (default true)
```
Things to consider:
* Buildkit warnings should be disabled when piping output (for example when using `--report-type json`), but this is _not forced_
* The `regexp2` engine is default because it supports full regular expression syntax. Compare differences in [regexp2's README](https://github.com/dlclark/regexp2#compare-regexp-and-regexp2). Note that `regexp2` patterns are not run in compatibility mode in docked, although that might change later.
* `viper` configuration is work-in-progress. Feel free to contribute.
## Configuration
The optional configuration file follows this example syntax:
```
ignore:
- D7:tagged-latest
rule_overrides:
'D5:secret-aws-access-key': low
custom_rules:
- name: custom-name
summary: Your custom summary
details: Your additional rule details
pattern: '.' # some regex pattern
priority: critical
command: add
```
## Build
Build a local distribution for evaluation using goreleaser (easiest).
```bash
goreleaser release --skip-publish --snapshot --rm-dist
```
This will create an executable application for your os/architecture under `dist`:
```
dist
├── docked_darwin_amd64
│ └── docked
├── docked_linux_386
│ └── docked
├── docked_linux_amd64
│ └── docked
├── docked_linux_arm64
│ └── docked
├── docked_linux_arm_6
│ └── docked
└── docked_windows_amd64
└── docked.exe
```
Build and execute locally using go:
* Get dependencies
```shell
go get -d ./...
```
* Build
```shell
go build -o docked ./cmd/docked/
```
* Run
```shell
./docked --help
```
## License
This project is [licensed](./LICENSE) under Apache 2.0.