projectatomic/dockerfile-lint is one of a Dockerfile Linter which can parse and detect syntactical errors in Dockerfile
Usage
It can be called using Docker CLI as shown below
In the above command, I had a Docker file in my current directory and my current directory is mounted under /root inside the container. The above command created the container from the image projectatomic/dockerfile-lint and it ran the command dockerfile_lint from inside the container. The dockerfile_lint is a node script available in the PATH inside the container.
docker run -i --rm -v `pwd`:/root:ro projectatomic/dockerfile-lint dockerfile_lint--------INFO---------INFO: There is no 'EXPOSE' instruction. Without exposed ports how will the service of the container be accessed?.Reference -> https://docs.docker.com/engine/reference/builder/#exposeINFO: There is no 'CMD' instruction. None.Reference -> https://docs.docker.com/engine/reference/builder/#cmd
The above run gave 2 warnings that there is no "EXPOSE" and "CMD" instruction defined in the provided Dockerfile.
Here is an example of a Dockerfile with error
Can you guess the issue in the Dockerfile which I provided by looking at the error? Hell!!
docker run -i --rm -v `pwd`:/root:ro projectatomic/dockerfile-lint dockerfile_lint/opt/dockerfile_lint/lib/parser.js:454while ((isComment(lines[i].trim()) || !lines[i].trim()) && (i < lines.length)) {^TypeError: Cannot read property 'trim' of undefinedat Object.parse (/opt/dockerfile_lint/lib/parser.js:454:39)at Linter.validate (/opt/dockerfile_lint/lib/linter.js:106:27)at lint (/opt/dockerfile_lint/bin/dockerfile_lint:85:33)at lintDockerFile (/opt/dockerfile_lint/bin/dockerfile_lint:104:9)at Object.<anonymous> (/opt/dockerfile_lint/bin/dockerfile_lint:144:5)at Module._compile (module.js:570:32)at Object.Module._extensions..js (module.js:579:10)at Module.load (module.js:487:32)at tryModuleLoad (module.js:446:12)at Function.Module._load (module.js:438:3)
I ended RUN command with "&&" , but I haven't provided next statement, as shown below
I hope this tool returns some better error message !!
RUN apk --update add sudo python py-pip && \apk --update add build-dependencies python-dev && \
No comments:
Post a Comment