Multiple ENTRYPOINT Instructions Listed
- Query id: 6938958b-3f1a-451c-909b-baeee14bdc97
- Query name: Multiple ENTRYPOINT Instructions Listed
- Platform: Dockerfile
- Severity: Low
- Category: Build Process
- CWE: 1041
- Risk score: 0.6
- URL: Github
Description¶
There can only be one ENTRYPOINT instruction in a Dockerfile. Only the last ENTRYPOINT instruction in the Dockerfile will have an effect
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - dockerfile file
FROM golang:1.7.3
WORKDIR /go/src/github.com/foo/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 alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=0 /go/src/github.com/foo/href-counter/app .
ENTRYPOINT [ "/opt/app/run.sh", "--port", "8080" ]
ENTRYPOINT [ "/opt/app/run.sh", "--port", "8000" ]
Positive test num. 2 - dockerfile file
from golang:1.7.3
workdir /go/src/github.com/foo/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 alpine:latest
run apk --no-cache add ca-certificates
workdir /root/
copy --from=0 /go/src/github.com/foo/href-counter/app .
entrypoint [ "/opt/app/run.sh", "--port", "8080" ]
entrypoint [ "/opt/app/run.sh", "--port", "8000" ]
Code samples without security vulnerabilities¶
Negative test num. 1 - dockerfile file
FROM golang:1.7.3
WORKDIR /go/src/github.com/foo/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 .
ENTRYPOINT [ "/opt/app/run.sh", "--port", "8080" ]
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=0 /go/src/github.com/foo/href-counter/app .
ENTRYPOINT [ "/opt/app/run.sh", "--port", "8080" ]
Negative test num. 2 - dockerfile file
FROM golang:1.16 AS builder
WORKDIR /go/src/github.com/foo/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 .
ENTRYPOINT [ "/opt/app/run.sh", "--port", "8080" ]
ENTRYPOINT [ "/opt/app/run.sh", "--port", "8000" ]
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /go/src/github.com/foo/href-counter/app ./
CMD ["./app"]
RUN useradd -ms /bin/bash patrick
USER patrick
Negative test num. 3 - dockerfile file
from golang:1.7.3
workdir /go/src/github.com/foo/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 .
entrypoint [ "/opt/app/run.sh", "--port", "8080" ]
from alpine:latest
run apk --no-cache add ca-certificates
workdir /root/
copy --from=0 /go/src/github.com/foo/href-counter/app .
entrypoint [ "/opt/app/run.sh", "--port", "8080" ]