https://github.com/bvwells/hadolint-example
Hadolint Dockerfile Linting Example
https://github.com/bvwells/hadolint-example
container hadolint linting security
Last synced: 5 months ago
JSON representation
Hadolint Dockerfile Linting Example
- Host: GitHub
- URL: https://github.com/bvwells/hadolint-example
- Owner: bvwells
- License: mit
- Created: 2022-03-07T14:32:18.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-17T16:55:56.000Z (over 4 years ago)
- Last Synced: 2025-11-30T04:07:22.554Z (8 months ago)
- Topics: container, hadolint, linting, security
- Language: Dockerfile
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hadolint Example
This repo shows an example of linting a Docker file with [Hadolint](https://github.com/hadolint/hadolint).
The repo contains two Dockerfiles, the original Dockerfile which Hadolint identifies issues with.
Run the command:
```bash
docker run --rm -i hadolint/hadolint < original/Dockerfile
```
This command produces the output:
```bash
-:6 DL3018 warning: Pin versions in apk add. Instead of `apk add ` use `apk add =`
-:6 DL3019 info: Use the `--no-cache` switch to avoid the need to use `--update` and remove `/var/cache/apk/*` when done installing packages
-:11 DL3047 info: Avoid use of wget without progress bar. Use `wget --progress=dot:giga `.Or consider using `-q` or `-nv` (shorthands for `--quiet` or `--no-verbose`).
```
See [rules](https://github.com/hadolint/hadolint#rules) for more information on
how to fix these issues.
Note: when pinning alpine package versions it is useful to refer to the official
alpine package management site [here](https://pkgs.alpinelinux.org/packages). Also,
it is possible to idenitfy the versions of packages by building the Docker image
without pinning the versions and then run `apk info *package*` within the running
container to see the version which was installed without pinning.
To build the Dockerfiles run
```bash
cd original && docker build -t bvwells/hadolint-example/original .
```
```bash
cd updated && docker build -t bvwells/hadolint-example/updated .
```