Giter Club home page Giter Club logo

dockerlint's People

Contributors

aerostitch avatar colinhebert avatar cstrouse avatar gaul avatar hobti01 avatar it-as avatar jasperla avatar jesugmz avatar laurentgoderre avatar mschuchard avatar mulmschneider avatar reinerj avatar reverbc avatar rnagy avatar shadiakiki1986 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dockerlint's Issues

Possible false positive for comments within a run command.

Issue details

I'm getting an Empty / bogus instruction is invalid but i'm pretty sure its ok.

Steps to reproduce/test case

This is part of my dockerfile. This runs correctly in docker.

RUN apk update \
  # psycopg2 dependencies
  && apk add --virtual build-deps gcc python3-dev musl-dev \
  && apk add postgresql-dev \

I have multiple lines after this one that start with && and they do not have this error.

Affected version(s)

Latest, used by this repo (AtomLinter/linter-docker) which is a wrapper for redcoolbeans/dockerlint. Link to other issue.</>

Support magic comment for ignoring specific blocks

E.g., I need an ADD in order to copy and extract a stage3 tarball for building a Gentoo container. Docker doesn't yet have an "EXEC" command to accomplish this. I want to lint my Dockerfile, but ignore the necessary ADD.

Custom Rules

Issue details

Hi Team,

I wanted to understand if there is a way to add my custom rules without having to write any code ?
Is there any configuration file maintained where rules can be added/modified/removed?

-Soumyadeep

False positive on RUN scripts with square brackets

Issue details

False positive on RUN with square brackets [ in the script.
If a script in RUN has square brackets (see test and [) and the expression evaluated contains single quotes, then docker lint will show Arguments to RUN in exec form must not contain single quotes on line even though this is not the exec form

Steps to reproduce/test case

RUN if [ 'test' = 'test' ]; then echo oops; fi

Affected version(s)

0.3.1

Support for ARG

Issue details

Unfortunately the ARG instruction is not supported the way that ENV is, causing incorrect errors.

Steps to reproduce/test case

FROM scratch
ARG HOME=/home/app
WORKDIR $HOME
docker run -v "$PWD/Dockerfile":/Dockerfile:ro redcoolbeans/dockerlint
...
ERROR: WORKDIR path $HOME contains undefined ENV variable on line 3
ERROR: /Dockerfile failed.

Affected version(s)

0.3.1

        "RepoTags": [
            "redcoolbeans/dockerlint:latest"
        ],
        "RepoDigests": [
            "redcoolbeans/dockerlint@sha256:5c11597ac2ed10d2aa32db3360548b8fe9635a52078c05778d17f6359b96f2f1"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2017-08-25T06:00:29.762704377Z",

How to use Docker image in GitLab CI

Issue details

I'm new to Docker and GitLab CI, and I want to use your redcoolbeans/dockerlint image in GitLab CI to test my Dockerfile before trying to rebuild the image. However running the redcoolbeans/dockerlint image results in an error.

Steps to reproduce/test case

I have a GitLab repo which contains a Dockerfile for an image I want to build, and a .gitlab-ci.yml config file for the CI tests.

# .gitlab-ci-yml
variables:
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME

stages:
  - check
  - build

dockerlint:
  image: redcoolbeans/dockerlint
  stage: check
  script:
    - ""
  only:
    - branches

build:
  image: docker:latest
  services:
    - docker:dind
  stage: build
  script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - docker build -t $IMAGE_TAG .
    - docker push $IMAGE_TAG
  tags:
    - dind

As I understand it, redcoolbeans/dockerlint has an ENTRYPOINT which makes it execute dockerlint on a Dockerfile in the current directory, so I shouldn't need to specify a script directive in my CI config. However, script is a mandatory parameter so I've set it to a blank script.

The output of my CI test fails with:

Running with gitlab-ci-multi-runner 9.5.1 (96b34cc)
  on dind (a5785152)
Using Docker executor with image redcoolbeans/dockerlint ...
Using docker image sha256:f8e4bcf6d77d0ed4db3fe044ad5cbc48d147d388e392989df13626b710479ad7 for predefined container...
Pulling docker image redcoolbeans/dockerlint ...
Using docker image redcoolbeans/dockerlint ID=sha256:ef2fc2ba2a1ce83fefd113345ecc551b98ab04c326208b92db060177b5e9e0f0 for build container...
Running on runner-a5785152-project-257-concurrent-0 via gitlab-ci-dv0.isys.bris.ac.uk...
Fetching changes...
HEAD is now at 8b2334c Try setting a blank script
From https://git.services.bristol.ac.uk/resnet/netops-ci
   8b2334c..ff53251  ci         -> origin/ci
Checking out ff532510 as ci...
Skipping Git submodules setup
ERROR: Cannot open sh.
ERROR: Cannot open sh.
ERROR: Job failed: exit code 1

It looks like GitLab CI is trying to use /bin/sh as the shell and failing. I tried overriding the entrypoint of your image to /bin/sh and then making the script manually execute dockerlint Dockerfile but this failed with the same error.

Is the cause of the problem that the image doesn't contain a shell? Any ideas how I can work around this with GitLab CI? I couldn't find any examples online of people using this image with GitLab CI. Hopefully it's a simple fix but I'm just too inexperienced with Docker.

Affected version(s)

Latest docker image:

f8e4bcf6d77d0ed4db3fe044ad5cbc48d147d388e392989df13626b710479ad7

False positive on the use of SUDO

Issue details

I have a Dockerfile containing the following line:
RUN echo "jenkins ALL=(ALL) ALL" >> etc/sudoers
which to my knowledge is not running a command with sudo

if i run dockerlint Dockefile, i get the following message

WARN: sudo(8) usage found on line 35 which is discouraged

False positive: Incorrect error when ENTRYPOINT args contain commas

Issue details

If any of the ENTRYPOINT args contain a comma, it will be marked as an error even though it's inside double-quotes.

Steps to reproduce/test case

  1. This valid input
# Dockerfile
FROM alpine
ENTRYPOINT ["echo", "hello,world"]
  1. Gives off this incorrect warning
    screen shot 2016-11-01 at 6 28 28 pm

Affected version(s)

dockerlint version 0.2.0, on OSX

Repo Maintenance

Issue details

Repo is not being maintaned

Steps to reproduce/test case

Look at the issues, some are a year old

Affected version(s)

0.3.1

should not require WORKDIR to be absolute path

Issue details

The linter complains about WORKDIR calls that do not include absolute paths.

WORKDIR /
WORKDIR go

The linter complains about the second line above, however, the dockerfile reference documentation clearly states that WORKDIR calls with relative paths will result in the path relative to the previous WORKDIR calls.
https://docs.docker.com/engine/reference/builder/#workdir

Steps to reproduce/test case

Add a WORKDIR call to a Dockerfile that does not include an absolute path (i.e. has a relative path)
Run using AtomLinter/linter-docker (wrapper for dockerlint)

Affected version(s)

Installed v0.3.2 of AtomLinter/linter-docker which has a dockerlint dependency v0.3.9

Same for docker-compose

Hello,
It's incredible!
Do you know if there is something that does the same thing with docker-compose files ?

WORKDIR should allow env variables

Issue details

Using an environment variable as WORKDIR should be allowed.

Steps to reproduce/test case

This is valid syntax in a Dockerfile:

ENV MY_PATH=/var/foo
WORKDIR $MY_PATH

But dockerlint says WORKDIR path $MY_PATH must be absolute.

Affected version(s)

  • linter-docker v0.1.2

Linter does not follow ESCAPE directive

As specified in Dockerfile reference:

# escape=\
# escape=`
The escape directive sets the character used to escape characters in a Dockerfile. If not specified, the default escape character is \.
The escape character is used both to escape characters in a line, and to escape a newline. This allows a Dockerfile instruction to span multiple lines. Note that regardless of whether the escape parser directive is included in a Dockerfile, escaping is not performed in a RUN command, except at the end of a line.
Setting the escape character to ` is especially useful on Windows, where \ is the directory path separator. ` is consistent with Windows PowerShell.

linter-docker does not currently check the escape directive and will report a line error if another character is used.

Add a programmatic API

Issue details

I was considering to use dockerlint programmatically, but it looks like there is no public programmatic API.

Steps to reproduce/test case

const dockerlint = require("dockerlint");

causes

ERROR: Cannot open Dockerfile.

and exits with code 1.

Affected version(s)

0.3.1

Comments not parsed correctly if at beginning of file

Issue details

If the Dockerfile starts with a comment whose line starts with a sequence of more than one pound sign (#) the parser does not recognize the line as a comment and prints the following error message

ERROR: First instruction must be 'FROM', is: ####

Steps to reproduce/test case

Create a Dockerfile that starts with a comment such as below and run it through the linter:

#### BUILDER
FROM alpine:edge AS builder

Affected version(s)

I used the docker image, tag is 0.3.1.

Failing to parse multi-line CMD properly

Issue details

dockerlint gives an error "No closing bracket found" given this valid instruction:

CMD ["foo",\
  "bar"]

Steps to reproduce/test case

Try to lint a Dockerfile with a multi-line CMD instruction...

Affected version(s)

0.2.0, as used inside linter-docker in Atom

ERROR: ENV invalid format when ENV followed with `\`

Issue details

First occurrence of ENV followed with \ to improve readability show error as invalid format:
ERROR: ENV invalid format ,TEST1=test1,SUPA1=supa1 on line 1
Second occurrence is not marked.

I would like to not have this error because such code is more readable for me.

Steps to reproduce/test case

Run dockerlint against following Dockerfile

FROM scratch

ENV \
    TEST1=test1 \
    SUPA1=supa1

ENV \
    TEST2=test2 \
    SUPA2=supa2

Other example: https://github.com/umputun/baseimage/blob/master/base.alpine/Dockerfile#L3

Affected version(s)

Dockerlint 0.3.9

undefined ARG or ENV variable when using variables from base image

Issue details

I am using an ENV variable that is defined in the base image, dockerlint doesn't like it:

ERROR: RUN contains undefined ARG or ENV variable on line 3

That variable is defined in the base image specifically for using it in descendant images.

How do I tell dockerlint that that ENV variable is defined?

Steps to reproduce/test case

FROM php:fpm-alpine

RUN apk add --no-cache $PHPIZE_DEPS \
    && pecl install ast \
    && docker-php-ext-enable ast \
    && apk del $PHPIZE_DEPS

Affected version(s)

Latest redcoolbeans/dockerlint Docker image.

RUN contains undefined ARG or ENV variable for a very defined ARG variable

Issue details

This seems different from #47 and #49

Steps to reproduce/test case

This should not raise any issues:

ARG FOO

RUN [[ -n "$FOO" ]]

It raises:

ERROR: Arguments to RUN in exec form must not contain single quotes on line 26
ERROR: RUN contains undefined ARG or ENV variable on line 26

Affected version(s)

0.3.1 and 0.3.9 are affected.

Does not catch error in invalid RUN command

Issue details

Linter does not catch error in invalid RUN command

Steps to reproduce/test case

Dockerfile:

FROM ruby:2.1.5

RUN
 apt-get update && apt-get install -y libxslt-dev libxml2-dev screen rsync

Here is output of docker build command:

Error response from daemon: Dockerfile parse error line 4: unknown instruction: APT-GET

Here is output of dockerlint:

INFO: Dockerfile is OK.

Same goes for cases:

RUN apt-get update
 && apt-get install -y libxslt-dev libxml2-dev screen rsync
RUN apt-get update \\
 && apt-get install -y libxslt-dev libxml2-dev screen rsync
RUN apt-get update \
 && apt-get install -y
libxslt-dev libxml2-dev screen rsync

Environment

dockerlint: 0.3.1
node: v7.10.1
npm: 4.2.0
docker: 17.09.0-ce, build afdb6d4
OS: macOS Sierra 10.12.6

False positive (error) on multiple comments during a line continuation

Issue details

In my Dockerfile I have my ENV instructions reduced to 1 layer. (per the example at: https://docs.docker.com/engine/reference/builder/#env)

I have some comments during a line continuation using #

Steps to reproduce/test case

Dockerfile with multiple env instructions on one layer.
Specifically 3 comment lines in a row, during a line continuation.

Here is a Dockerfile I am able to reproduce this with:

FROM centos
ENV FOO=fooo \
    BAR=/opt/bar \
    BAS=elk \
# 
#  Baz does baz things
#
    BAZ=/opt/baz\ /r \
    BAN=/opt/ban

Affected version(s)

[email protected]

Incorrect ARG warning in multistage dockerfile

Issue details

If you have an ARG that you'd like to be shared for all stages, the convention is to do the following:

# This is global.
ARG FOO=/path/to/something

FROM alpine:latest as base1
# Call `ARG` with just the key to load the variable from global.
ARG FOO
COPY $FOO/bar .
WORKDIR $FOO

The linter will then say:

COPY contains undefined ARG or ENV
WORKDIR path $FOO must be absolute

Steps to reproduce/test case

See description above

Affected version(s)

master

Trailing Spaces Error on Commented Lines

Issue details

Remove the trailing spaces check on comment lines

Steps to reproduce/test case

Add a comment with a trailing space

# this is a test  

then run the dockerlint

Affected version(s)

master

Repeated error messages for the same error on version 0.3.5

When using version 0.3.5 dockerlint repeats the same erros.

You may reproduce this by linting a Dockefile containing the following content:

FROM someimage
ENV	ENV_VARIABLE

The output is:

ERROR: ENV invalid format ENV_VARIABLE on line 2
ERROR: ENV invalid format ENV_VARIABLE on line 2
ERROR: ENV invalid format ENV_VARIABLE on line 2

ERROR: spec/fixtures/bad/Dockerfile failed.

When using dockerlint version 0.3.1 the output is:

ERROR: ENV invalid format ENV_VARIABLE on line 2

ERROR: spec/fixtures/bad/Dockerfile failed.

Linting fails for ENV rule including '=' symbol

Issue details

Linting fails for ENV rule including '=' symbol.

Steps to reproduce/test case

Example

FROM	postgres:9.6

ENV		POSTGRES_INITDB_ARGS --auth-host=md5
ERROR: ENV cannot mix the two formats for declaring variables line 3

Affected version(s)

0.2.2 (Commit 1fa5bfe)

Recurse over directories

As a developer, I want dockerlint to automatically look for any and all Dockerfile* paths within directory trees, so that I can quickly lint large projects that have many Dockerfile's.

Escaped new lines after keywords not supported

Steps to reproduce/test case

$ cat > Dockerfile << 'EOF'
FROM centos

CMD \
  ["bash"]
EOF

$ dockerlint Dockerfile
check: from_first
check: no_empty_tag
check: no_empty_digest
check: json_array_brackets
check: json_array_even_quotes
check: json_array_format
DEBUG:'Arg: ["bash"]'
check: recommended_exec_form
WARN:  Recommended exec/array form not used on line 3
check: add
check: multiple_entries
check: sudo
check: absolute_workdir
check: onbuild_copyadd
check: onbuild_disallowed
check: label_no_empty_value

ERROR: Dockerfile failed.

Affected version(s)

Dockerlint 0.2.0

False positive on empty ENTRYPOINT

Issue details

I use an empty ENTRYPOINT in my Dockerfile to explicitly reset the ENTRYPOINT defined by the parent docker image.
Dockerlint falsely claims that this line contains single quotes:

ERROR: Arguments to ENTRYPOINT in exec form must not contain single quotes on line 2

Steps to reproduce/test case

FROM certbot/certbot
ENTRYPOINT []

Affected version(s)

both master and 0.3.1

Parser doesn't count the lines correctly on Windows

I got the following output when attempting to run the tests for dockerlint v0.1.4 on Windows:

  1) parser should count the lines correctly:

      AssertionError: expected 6 to deeply equal 8
      + expected - actual

      -6
      +8

    at Assertion.assertEqual (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\chai\lib\chai\core\assertions.js:439:19)
    at Assertion.ctx.(anonymous function) [as equal] (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\chai\lib\chai\utils\addMethod.js:40:25)
    at Context.<anonymous> (C:\Users\Landon Abney\Documents\GitHub\dockerlint\test\parserTest.coffee:45:68)
    at callFn (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runnable.js:286:21)
    at Test.Runnable.run (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runnable.js:279:7)
    at Runner.runTest (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:421:10)
    at C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:528:12
    at next (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:341:14)
    at C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:351:7
    at next (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:283:14)
    at Immediate._onImmediate (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:319:5)

I'm guessing this is a combination of two things:

  • There is no .gitattributes file specifying the line endings for files in this repository, so on Windows it is defaulting to CRLF.
  • The parser may not be counting CRLF lines properly?

This test works correctly on my Ubuntu virtual machine.

Note:
As make isn't defined by default I was simply running the following manually:

.\node_modules\.bin\mocha --require coffee-script/register --require chai --reporter spec --compilers coffee:coffee-script/register test/*.coffee

Parser doesn't handle line continuations correctly on Windows

When running the tests for dockerlint v0.1.4 on Windows I got the following output:

2) parser should handle line continuations:

    AssertionError: expected [ Array(5) ] to deeply equal [ Array(3) ]
    + expected - actual

       }
       {
         "arguments": [
           "yum update &&"
    +      "yum install mg &&"
    +      "yum upgrade"
         ]
         "instruction": "RUN"
         "line": 3
       }
       {
         "arguments": [
    -      "yum install mg &&"
    -    ]
    -    "instruction": ""
    -    "line": 4
    -  }
    -  {
    -    "arguments": [
    -      "yum upgrade"
    -    ]
    -    "instruction": ""
    -    "line": 5
    -  }
    -  {
    -    "arguments": [
           "yum -y update && \\\\ yum -y install tmux"
         ]
         "instruction": "RUN"
         "line": 7

  at Assertion.assertEqual (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\chai\lib\chai\core\assertions.js:439:19)
  at Assertion.ctx.(anonymous function) [as equal] (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\chai\lib\chai\utils\addMethod.js:40:25)
  at Context.<anonymous> (C:\Users\Landon Abney\Documents\GitHub\dockerlint\test\parserTest.coffee:53:68)
  at callFn (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runnable.js:286:21)
  at Test.Runnable.run (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runnable.js:279:7)
  at Runner.runTest (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:421:10)
  at C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:528:12
  at next (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:341:14)
  at C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:351:7
  at next (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:283:14)
  at Immediate._onImmediate (C:\Users\Landon Abney\Documents\GitHub\dockerlint\node_modules\mocha\lib\runner.js:319:5)

And since the output is much nicer looking with color, here is a screenshot of the first part:
image

I'm not sure what the issue is here, although I wouldn't be surprised if this is related to the file being checked out as CRLF on Windows by default. This test passes on my Ubuntu virtual machine.

If you need any further information please let me know.

Note:
As make isn't defined by default I was simply running the following manually:

.\node_modules\.bin\mocha --require coffee-script/register --require chai --reporter spec --compilers coffee:coffee-script/register test/*.coffee

Empty files crash dockerlint

When attempting to run dockerlint v0.1.4 on a file that is effectively empty, it crashes.

Here is what I get in an Ubuntu virtual machine when running dockerlint test/dockerfiles/empty:

abneyl@ubuntu:~/Documents/GitHub/dockerlint$ dockerlint test/dockerfiles/empty 
/usr/lib/node_modules/dockerlint/lib/checks.js:41
    if (first.instruction !== 'FROM') {
             ^

TypeError: Cannot read property 'instruction' of undefined
    at Object.exports.from_first (/usr/lib/node_modules/dockerlint/lib/checks.js:41:14)
    at Object.exports.run (/usr/lib/node_modules/dockerlint/lib/cli.js:50:24)
    at Object.<anonymous> (/usr/lib/node_modules/dockerlint/bin/dockerlint.js:17:7)
    at Object.<anonymous> (/usr/lib/node_modules/dockerlint/bin/dockerlint.js:19:4)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:430:10)
    at startup (node.js:141:18)

Windows has the same issue, only the paths are different. The comment_only file exhibits the same behavior.

Tag new release and update npm

Version 0.2.0 is a year old and more than 10 commits have been merged since the release including fixes to typos in output messages. Time to do a new release?

No warning for error "ENV must have two arguments"

When declaring an ENV variable its value must be declared too.

When running the linter for the following content of a Dockerfile on earlier versions of dockerlint I received the error ERROR: ENV invalid format ENV_VARIABLE. However, the same error is not displayed anymore since the release 0.3.6

FROM  someimage
ENV  ENV_VARIABLE

ENV requires to be followed by both a key and a value. When trying to build a Dockerfile containing the content above, Docker displays Error response from daemon: ENV must have two arguments.

So, it seems that dockerlint should go back to the earlier behavior and display an error message in such situation.

Related to #46

ARG linting falsely requires optional default value

Issue details

ARGs without a default value create an 'invalid format' error (see below), even though they are perfectly valid according to the docker reference docs.

Also, the same error message is printed three times.

Steps to reproduce/test case

$ cat /tmp/Dockerfile 
FROM busybox
ARG user1
ARG buildno
$ make js && coffee bin/dockerlint.coffee -f /tmp/Dockerfile 
npm install
coffee -c bin/dockerlint.coffee
coffee -o lib -c src
# Insert shebang so the resulting script runs standalone
{ echo '#!/usr/bin/env node '; cat bin/dockerlint.js; } > bin/dockerlint.js.tmp
mv bin/dockerlint.js.tmp bin/dockerlint.js
ERROR: ARG invalid format user1 on line 2
ERROR: ARG invalid format user1 on line 2
ERROR: ARG invalid format user1 on line 2

ERROR: /tmp/Dockerfile failed.

Affected version(s)

master

No warning for error "ENV must have two arguments"

Issue details

When declaring an ENV variable, the variable must be defined. This issue appeared in the latest version of dockerlint.

Steps to reproduce/test case

file /tmp/dockerlint/Dockerfile

FROM alpine:3.6
ENV ENV_VARIABLE

Running docker build /tmp/dockerlint returns:

Sending build context to Docker daemon  2.048kB
Error response from daemon: ENV must have two arguments

But running dockerlint /tmp/dockerlint/Dockerfile returns:

INFO: /tmp/dockerlint/Dockerfile is OK.

Affected version(s)

Version 0.3.8 of dockerlint is affected.

I am running the latest version of docker (18.03.0-ce), I have also tested using 17.x.

Related to #48

False Positive for DL3020

Issue details

When extracting a compressed tar file with .tgz suffix, falsely identifies as requiring COPY instead.
:3 DL3020 Use COPY instead of ADD for files and folders

Need to add all suffixes from Wikipedia Tar Suffixes

Steps to reproduce/test case

Tar and use Add .tgz in dockerfile and see request to use COPY not ADD.

Affected version(s)

Git sha1: 22e1eef5815e1e970c2b488998266505fe5d300b

Super minor typo

Issue details

errmsg = "Arguments to #{i} in exec for must not contain single quotes on line #{r.line}"

Arguments to ENTRYPOINT in exec for must not contain single quotes --> Arguments to ENTRYPOINT in exec form must not contain single quotes

Very minor, but still can be confusing initially when displayed.

Check for absolute WORKDIR should resolve variables

I have received the following error with $INSTALLPATH set to /app
ERROR: WORKDIR path $INSTALLPATH must be absolute on line 20

$INSTALLPATH was set via ENV like this
ENV INSTALLPATH /app

The check should resolve environment variables.

Exception thrown for Dockerfile with multiple ENV rules

Issue details

TypeError thrown for Dockerfile with multiple ENV rules.

Steps to reproduce/test case

Example

FROM	postgres:9.6

ENV		POSTGRES_PASSWORD test
ENV		POSTGRES_INITDB_ARGS test
<...>\node_modules\dockerlint\lib\checks.js:257
      for (k = 0, len1 = ref.length; k < len1; k++) {
                            ^

TypeError: Cannot read property 'length' of undefined
    at Object.exports.env (<...>\node_modules\dockerlint\lib\checks.js:257:29)
    at Object.exports.run (<...>\node_modules\dockerlint\lib\cli.js:54:24)
    at Object.<anonymous> (<...>\node_modules\dockerlint\bin\dockerlint.js:17:7)
    at Object.<anonymous> (<...>\node_modules\dockerlint\bin\dockerlint.js:19:4)
    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)
    at Module.runMain (module.js:604:10)

Affected version(s)

0.2.2 (Commit 1fa5bfe)

Discussion: How would the --version feature work?

In the roadmaps section of the readme, there's mention of a --version flag that checks against the Docker version. Can anyone expand on the mechanics of this proposed feature?

I find this package to be useful. If it doesn't take too much time to develop, I'd be willing to give it a shot at implementation.

ENV invalid when environment variable contains excaped $

I can not find the way to escape the variable value:

ENV SOME_PASSWORD=ASDFLKJSDLKFJK?^\$9

The $ sign is not variable - it is escaped. For me and docker it's ok, I get correct value inside docker, but dockerlint complains:

docker run -it --rm -v "$PWD/Dockerfile":/Dockerfile:ro redcoolbeans/dockerlint
ERROR: ENV contains undefined ARG or ENV variable on line 13
ERROR: Lines cannot have trailing spaces

ERROR: /Dockerfile failed.

Is it bug or feature? How to hold such values in the Dockerfile?

I use latest version:
redcoolbeans/dockerlint latest bf4955dfb649 11 days ago 41.5MB

ADD instruction used instead of COPY

Issue details

Getting an ADD instruction used instead of COPY warning on a line like:

ADD https://example.com/foo /foo

COPY doesn't support pulling from URLs, so obviously COPY could not be used in this case.

While it's often preferable to use COPY, there are valid use cases for ADD that should not be discouraged. See: https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/add-or-copy

Steps to reproduce/test case

Lint a Dockerfile with an ADD instruction that unrolls a tarball or pulls from a URL

Affected version(s)

0.2.0 (used inside linter-docker in Atom)

Absolute path for WORKDIR false positive on Windows

The absolute path rule for the work dir gives an error on Windows when the Dockerfile does contain an absolute path.

WORKDIR /data

On windows the check recognizes this path as relative where on Linux it works properly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.