Giter Club home page Giter Club logo

Comments (3)

prasenjithaty avatar prasenjithaty commented on August 22, 2024

I guess the issue is that the linter does not support Docker multi-stage builds yet introduced in Docker 17.05 and errors out with:

The first instruction in a Dockerfile must specify the base image using a FROM command. Additionally, FROM cannot appear later in a Dockerfile.

from dockerfilelint.

alexellis avatar alexellis commented on August 22, 2024

How about now?

from dockerfilelint.

mildebrandt avatar mildebrandt commented on August 22, 2024

I think this was fixed too well. It does warn on both latest tags in the FROM statements....but it doesn't like the reference to a previous stage.

I changed the Dockerfile to this:

FROM golang:latest as builder
WORKDIR /go/src/github.com/alexellis/href-counter/
RUN go get -d -v golang.org/x/net/html
COPY app.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .

FROM builder
RUN ls -l /

FROM alpine:latest
RUN apk add ca-certificates
WORKDIR /root/
copy --from=builder /go/src/github.com/alexellis/href-counter/app .
CMD ["./app"]

And I get the following messages:

$ docker run --rm -it -v $PWD/Dockerfile:/Dockerfile replicated/dockerfilelint /Dockerfile

File:   /Dockerfile
Issues: 5

Line 1: FROM golang:latest as builder
Issue  Category      Title                 Description
    1  Clarity       Base Image Latest     Base images should not use the latest tag.
                     Tag

Line 7: FROM builder
Issue  Category      Title                 Description
    2  Clarity       Base Image Missing    Base images should specify a tag to use.
                     Tag

Line 10: FROM alpine:latest
Issue  Category      Title                 Description
    3  Clarity       Base Image Latest     Base images should not use the latest tag.
                     Tag

Line 11: RUN apk add ca-certificates
Issue  Category      Title                 Description
    4  Optimization  Consider `--no-cache  Consider using a `--no-cache` (supported in alpine linux >= 3.3) or
                     or --update with rm   `--update` followed by the command `rm -rf /var/cache/apk/*` when
                     -rf                   `apk` adding packages.  This will result in a smaller image size.
                     /var/cache/apk/*`     For
                                           more information, see [this
                                           link](https://github.com/gliderlabs/docker-alpine/blob/master/docs/
                                           usage.md)

Line 13: copy --from=builder /go/src/github.com/alexellis/href-counter/app .
Issue  Category      Title                 Description
    5  Clarity       Capitalize            For clarity and readability, all instructions in a Dockerfile
                     Dockerfile            should be uppercase.
                     Instructions          This is a convention adopted by most of the official images and
                                           greatly improves readability in long Dockerfiles.  For an example
                                           of
                                           why this makes a difference, check out the current [redis
                                           Dockerfile](https://github.com/docker-library/redis/blob/b375650fb6
                                           9b7db819e90c0033433c705b28656e/3.0/Dockerfile)
                                           and you should be able to easily see the instructions used.

I would not expect the Line 7: FROM builder message since it's referencing a previous stage.

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.