Code Inspections in Dockerfile
This topic lists all JetBrains Rider code inspections available in Dockerfile.
You can toggle specific inspections or change their severity level on the Editor | Inspection Settings | Inspection Severity | Other Languages page of settings Ctrl+Alt+S.
Inspection | Description | Default Severity |
---|---|---|
A single quoted string in JSON array format | Reports a single quoted string in JSON array format. JSON array form, must use double-quotes (") around words not single-quotes ('). Otherwise, Docker build will fail. Examples:
# all the commands below will fail
RUN ['/bin/bash', '-c', 'echo hello']
ADD ['binaryA.jar', 'binary2.jar', 'destination/']
COPY ['binaryA.jar', 'binary2.jar', 'destination/']
After the quick-fix is applied:
RUN ["/bin/bash", "-c", "echo hello"]
ADD ["binaryA.jar", "binary2.jar", "destination/"]
COPY ["binaryA.jar", "binary2.jar", "destination/"]
| |
Invalid destination for ''ADD''/''COPY'' commands | Reports invalid destination directories in According to the Dockerfile specification, if multiple sources are specified, then the destination must be a directory, and it must end with a slash '/'. Otherwise, Docker build will fail. Examples:
# all the commands below will fail
ADD textA.txt textB.txt relativeDir
ADD ["binaryA.jar", "binary2.jar", "destination"]
COPY text3.txt text4.txt /absolute/path
After the quick-fix is applied:
ADD textA.txt textB.txt relativeDir/
ADD ["binaryA.jar", "binary2.jar", "destination/"]
COPY text3.txt text4.txt /absolute/path/
| |
Invalid spaces in ''key=value'' pair | Reports incorrect spacing for key-value pairs in While it is not explicitly specified in the Dockerfile specification, some combinations of spacing for key-value pairs are not allowed. Docker build will fail after reaching the problem instruction. Examples:
# all the commands below will fail
ARG answer = 42
ARG version= "1.0.0"
LABEL "maintained.by"= someone@gmail.com
ENV JAVA_HOME= "/docker-java-home"
After the quick-fix is applied:
ARG answer=2
ARG version="1.0.0"
LABEL "maintained.by"=someone@gmail.com
ENV JAVA_HOME="/docker-java-home"
| |
Missing continuation character for ''RUN'' command | Reports missing continuation characters in In the shell form of Examples:
# the command below will fail
RUN /bin/bash -c 'source $HOME/.bashrc;
echo $HOME'
After the quick-fix is applied:
RUN /bin/bash -c 'source $HOME/.bashrc; \
echo $HOME'
| |
Wrong number of arguments | Reports invalid number of arguments for the Dockerfile commands. Docker build will fail after reaching the instruction with an invalid number of arguments. |