Giter Club home page Giter Club logo

Comments (6)

darkvertex avatar darkvertex commented on June 22, 2024 5

Found this issue after discovering there's no multistage support.

For anyone that needs such a thing, consider the alternative linter hadolint.

from dockerfilelint.

AmauryOrtega avatar AmauryOrtega commented on June 22, 2024 3

@SimonHeimberg I checked the Dockerfile posted by @AuthorProxy and the one I posted as an example in http://www.dockerfilelint.com and noticed that the line FROM base AS dependencies gives a warning because of the FROM <any_image>:<tag> is correctly using the image base but it doesn't have a tag associated to it.

dockerfilelint must be thinking that base is a published image and using the latest tag (assumed because the tag is not present) is not recommended.

The bug could be summarized into: When reusing stages with the FROM directive in a multistage Dockerfile, dockerfilelint gives a false positive warning for not having a tag associated to it.

from dockerfilelint.

AmauryOrtega avatar AmauryOrtega commented on June 22, 2024 1

@darkvertex Thanks!. The multistage Dockerfile I used as an example before shows no warnings on the online version of hadolint.

from dockerfilelint.

SimonHeimberg avatar SimonHeimberg commented on June 22, 2024 1

There are two online checkers using this tool:

But the other problem:
Both ask for a tag for line 15 (FROM base AS dependencies), which does not make sense (at least probably) because base is defined in the dockerfile. This also happens on version 1.5.0 running locally. The alternative hadolint does not have this problem.

from dockerfilelint.

Aylr avatar Aylr commented on June 22, 2024 1

@AmauryOrtega Thanks for this nice summary. I can confirm your findings.

from dockerfilelint.

AmauryOrtega avatar AmauryOrtega commented on June 22, 2024

@AuthorProxy This warning appears because you don't specify the tag on the FROM statements.
An example for a multistage build that doesn't show those warnings:

FROM node:8.4.0-slim as clientbuilder
WORKDIR /app
COPY src/main/frontend .
RUN yarn
RUN npm run build

FROM openjdk:8u141-jdk-slim as serverbuilder
WORKDIR /app
COPY . .
COPY --from=clientbuilder /app/dist /app/src/main/resources/static
RUN ./gradlew build

FROM openjdk:8-jre-alpine
ENV artifact app-0.0.1.jar
WORKDIR /app
COPY --from=serverbuilder /app/build/libs/${artifact} /app
EXPOSE 8080
ENTRYPOINT ["sh", "-c"]
CMD ["java -jar ${artifact}"]

In this case, the warning that appears are:

  • Line 8: First Command Must Be FROM (Possible Bug)
  • Line 15: First Command Must Be FROM (Possible Bug)

This is expected since there is no multistage support.

from dockerfilelint.

Related Issues (20)

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.