Complete the Dockerfile to use the minimal scratch base image.
FROM [1] COPY app /app CMD ["/app"]
The scratch image is an empty base image used for minimal containers.
Complete the Dockerfile to copy the binary into the scratch image.
FROM scratch COPY [1] /app CMD ["/app"]
The binary is usually built into a bin/ directory before copying.
Fix the error in the Dockerfile to run the binary correctly in scratch.
FROM scratch COPY app /app CMD ["[1]"]
In scratch, you must specify the full path to the binary in CMD.
Fill both blanks to create a minimal Dockerfile that builds a Go binary and uses scratch.
FROM golang:1.20 AS builder WORKDIR /src COPY . . RUN go build -o [1] . FROM [2] COPY --from=builder /src/[1] /app CMD ["/app"]
The Go binary is often named main by default, and the scratch image is used as the minimal base.
Fill all three blanks to create a minimal Dockerfile that builds a static Go binary and runs it in scratch.
FROM golang:1.20 AS builder WORKDIR /app COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o [1] . FROM [2] COPY --from=builder /app/[1] /[3] CMD ["/[3]"]
The binary is named main, the base image is scratch, and the binary is copied to /main in the container.