The recent posts about multi-stage docker builds produced containers that were still larger than needed. Likewise, tutorials I've found that start "FROM scratch" copy the ca-certificates.crt file from the local system. Here is a simple dockerfile which should portably produce the smallest container possible while still enabling networking: https://github.com/daved/goecho
FROM golang:1.8.1
ENV APP /app
WORKDIR /go/src${APP}/
COPY *.go .
RUN CGO_ENABLED=0 GOOS=linux; go build -a -tags netgo -
ldflags '-w' -o ${APP}
FROM scratch
ENV CERTS /etc/ssl/certs/ca-certificates.crt
COPY --from=0 ${CERTS} ${CERTS}
COPY --from=0 ${APP} ${APP}
EXPOSE 25000
ENTRYPOINT [ "/app" ]
- Docker 17.05 was posted to the "edge" release channel for Ubuntu a handful of hours ago. I assume that means it has also hit for other OSes.
评论:
Oliviaruth:
daveddev:Cool! Is this availible with docker hub automated builds yet?
:I think so too, thanks! I wish I could answer whether the above dockerfile is compatible with hub automated builds, but I don't use that feature. Nonetheless, my guess is that any valid dockerfile will work.
[deleted]
