Comments (3)
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.
How about now?
from dockerfilelint.
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)
- I want to use "apt update"
- Escaped quotes cause TypeError
- Invalid Argument for HEALTHCHECK HOT 7
- Please create a release HOT 6
- Add Support for Custom Rulesets
- Ability to supply "Severity" levels for rules
- Repo still actively maintained? HOT 2
- "Label Is Invalid" when period in label key
- Add support for yum commands
- Dead link for no-install-recommends
- Multi-Stage builds incorrectly expect a version label
- [v1.8.0] Rules ignored HOT 1
- Configuration file path enhancement HOT 1
- Missing tag rule should not apply to local multistage Dockerfiles HOT 6
- Invalid Port Exposed error HOT 1
- Active status & maintainers ? HOT 1
- Feature Request: Add Rule for EOF return
- Complaints of Base Image Missing Tag when tag is specified for Python
- Wrong error when creating a docker file that is using a base image from an argument
- Does not recognize error in wrong EXPOSE statement with a list of ports with a comma, e.g. "EXPOSE 8080, 8443" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dockerfilelint.