Dockerfiles
Docker images
Alpine stack
Alpine Linux
Download the Mini Root Filesystem from Alpine. Use the downloaded archive to create a Docker root:
docker import - docker.example.org/alpine:3.5.2 < alpine-minirootfs-3.5.2-x86_64.tar.gz
docker tag docker.example.org/alpine:3.5.2 docker.example.org/alpine:latest
Base
Dockerfile of the base image
FROM docker.example.org/alpine
RUN apk add --update --no-cache bash ca-certificates
CMD bash
Other
Go
- Onbuild
FROM golang:onbuild
EXPOSE 8080
- Multi stage
When running the resulting Dockerfile mount the COPY /etc/ssl/certs/ca-certificates.crt to /etc/ssl/certs/.
FROM golang:1.10 AS build
ARG pkg=github.com/example/my-service
WORKDIR /go/src/$pkg
COPY . .
# Dependencies (-d: download only without no install, -t: download test dependencies)
RUN go get -d -t ./...
# Analyze
RUN go vet ./... \
&& go get golang.org/x/lint/golint \
&& /go/bin/golint ./...
# Build (CGO_ENABLED=0: disable Go packages using C code)
RUN CGO_ENABLED=0 GOOS=linux go build -o /service .
FROM scratch
COPY --from=build /service .
ENTRYPOINT ["/service"]
Java
FROM openjdk:8-jdk
ARG JAR_FILE
VOLUME /tmp
ADD ./${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-verbose:gc","-XX:+PrintGCDetails","-XX:+PrintGCTimeStamps","-XX:+PrintCodeCache","-Xloggc:/tmp/gc.log","-XX:+UseGCLogFileRotation","-XX:NumberOfGCLogFiles=5","-XX:GCLogFileSize=2M" ,"-jar","/app.jar"]