Skip to content

Instantly share code, notes, and snippets.

View renatomefi's full-sized avatar
:octocat:
Wahoo!

Renato Mefi renatomefi

:octocat:
Wahoo!
View GitHub Profile
@renatomefi
renatomefi / docker-compose.yml
Created September 17, 2018 16:54
A docker-compose file for CoreOS Clair Scanner
version: '3.2'
services:
postgres:
container_name: clair_postgres
image: arminc/clair-db:latest
restart: unless-stopped
environment:
POSTGRES_PASSWORD: password
clair:

Dockerfile

FROM alpine:latest

Run

$ docker run --rm -i hadolint/hadolint hadolint -f json - < ./Dockerfile
[{"line":1,"code":"DL3007","message":"Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag","column":1,"file":"/dev/stdin","level":"warning"}]
ignored:
  - DL3007 # this was here before...
  - SC1068
FROM alpine:3.8
RUN my_repo = "http://myrepo.git" && cd /tmp && git clone $my_repo
$ docker run -v $(pwd):/project:ro --workdir=/project --rm -i hadolint/hadolint:latest-debian hadolint /project/Dockerfile
/project/Dockerfile:3 SC1068 Don't put spaces around the = in assignments.
/project/Dockerfile:3 DL3003 Use WORKDIR to switch to a directory
$ docker run -v $(pwd):/project:ro --workdir=/project --rm -i hadolint/hadolint:latest-debian \
hadolint /project/Dockerfile /project/Dockerfile-something-else
$ echo $?                                                                           
0

Command argument ignore

$ docker run --rm -i hadolint/hadolint hadolint --ignore DL3007 - <./Dockerfile
$ hadolint echo $?
0

Commenting above the issue on Dockerfile

$ docker run --rm -i hadolint/hadolint hadolint -c config.yaml - <./Dockerfile
$ docker run --rm -i hadolint/hadolint -c config.yaml < ./Dockerfile
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"-c\": executable file not found in $PATH": unknown.
FROM alpine:3.8

Run

$ docker run --rm -i hadolint/hadolint < ./Dockerfile         
$ echo $?
0

Create a Dockerfile

FROM alpine:latest

Run

$ docker run --rm -i hadolint/hadolint < ./Dockerfile
/dev/stdin:1 DL3007 Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag