DL3003 Use WORKDIR to switch directory false positive
#422 ouverte le 1 mai 2020
Métriques du dépôt
- Stars
- (12 138 étoiles)
- Métriques de merge PR
- (Merge moyen 5j 13h) (8 PRs mergées en 30 j)
Description
- This is a bug report
- This is a feature request
- I searched existing issues before opening this one
Expected behavior
When compiling software in a layer, it is often required to change directory, build, change back, and remove the sources. This must happen all within one RUN to avoid the sources remaining in a layer in the image. Therefore, the cd must happen within the RUN.
A suggestion to use WORKDIR should not apply to this pattern and so the lint error is a false-positive.
Actual behavior
Any cd within a RUN is flagged, including this pattern.
Steps to reproduce the behavior
RUN \
git clone git://github.com/jpmens/jo.git /tmp/jo && \
cd /tmp/jo && \
autoreconf -i && \
./configure && \
make check && \
make install && \
cd /tmp && \
rm -rf ./jo
I tried to follow the Rationale section of the wiki, which mentions a sub-shell:
RUN \
git clone git://github.com/jpmens/jo.git /tmp/jo && \
(cd /tmp/jo && \
autoreconf -i && \
./configure && \
make check && \
make install) && \
rm -rf /tmp/jo
but the lint error is still flagged for this. Maybe I'm doing that wrong?
Output of hadolint --version or
docker run --rm hadolint/hadolint hadolint --version:
Haskell Dockerfile Linter v1.17.6-0-gc918759