Docker

Docker

Made by DeepSource
Missing space before # DOK-SC1099
Bug risk
Major

A keyword is found immediately following a #. In order for the # to start a comment, it needs to come after a word boundary such as a space.

Unquoted literal string detected DOK-SC2140
Bug risk
Major

This warning is triggered when an unquoted literal string is found suspiciously sandwiched between two double quoted strings.

Detected $ on the left side of assignment DOK-SC1066
Bug risk
Critical

Unlike Perl or PHP, $ is not used when assigning to a variable.

Useless cat detected DOK-SC2002
Anti-pattern
Major

cat is a tool for concatenating files. Reading a single file as input to a program is considered a Useless Use Of Cat (UUOC). It's more efficient and less roundabout to simply use redirection. This is especially true for programs that can benefit from seekable input, like tail or tar. Many tools also accept optional filenames, e.g. grep -q foo file instead of cat file | grep -q foo.

Always tag the version of an image explicitly DOK-DL3006
Bug risk
Minor

You can never rely on the assumption that the latest tag points to a specific version of an image. Explicitly tagging the image with a specific version (e.g. ubuntu:12.04) ensures that your application will not break due to random changes across different versions of an image you depend on.

Pin versions in gem install DOK-DL3028
Bug risk
Major

Version pinning forces the build to retrieve a particular version regardless of what’s in the cache. This technique can also reduce failures due to unanticipated changes changes between different versions in required packages.

Invalid case used for command/syntax DOK-SC1081
Bug risk
Critical

Unexpected == detected DOK-SC1097
Bug risk
Major

== is being used in an unexpected way. The two most common reasons for this is: - You wanted to assign a value but accidentally used == instead of =.

Delete the apt-get lists after installing anything DOK-DL3009
Performance
Major

Cleaning up the apt cache and removing /var/lib/apt/lists helps keep the image size down. Since the RUN statement starts with apt-get update, the package cache will always be refreshed prior to apt-get install.

Use absolute WORKDIR DOK-DL3000
Bug risk
Minor

By using absolute paths you will not run into problems when a previous WORKDIR instruction changes. You also often don't know the WORKDIR context of your base container.

Command does not make sense in a container DOK-DL3001
Bug risk
Critical

For some POSIX commands it makes no sense to run them in a Docker container because they are bound to the host or are otherwise dangerous (like ´shutdown´, ´service´, ´ps´, ´free´, ´top´, ´kill´, ´mount´, ´ifconfig´). Interactive utilities also don't make much sense (´nano´, ´vim´).

User should not be root when the Dockerfile completes DOK-DL3002
Security
Critical

Switching to the root USER opens up certain security risks if an attacker gets access to the container. In order to mitigate this, switch back to a non privileged user after running the commands you need as root.

Pin image versions explicitly to a release tag DOK-DL3007
Bug risk
Major

Using the latest tag can cause breakages when a new version of an image is released. You can never rely on the assumption that the latest tag points to a specific version of an image.

Use the -y switch DOK-DL3014
Bug risk
Major

Without the -y/--assume-yes option it might be possible for the build to break without human intervention.

COPY --from should reference a previously defined FROM alias DOK-DL3022
Bug risk
Major

Trying to copy from a missing image alias results in an error.

COPY --from cannot reference its own FROM alias DOK-DL3023
Bug risk
Major

Trying to copy from the same image the instruction is running in results in an error.

FROM aliases (stage names) must be unique DOK-DL3024
Bug risk
Major

Defining duplicate stage names results in an error.

Multiple ENTRYPOINT instructions detected DOK-DL4004
Bug risk
Major

If you list more than one ENTRYPOINT then only the last ENTRYPOINT command will be setup, making prior ENTRYPOINT setups redundant.

eval used with special characters DOK-SC1098
Bug risk
Major

Shells differ widely in how they handle unescaped parentheses in eval expressions. eval foo=bar is allowed by dash, bash and ksh.