0
0
Dockerdevops~10 mins

Scratch base image for minimal containers in Docker - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the Dockerfile to use the minimal scratch base image.

Docker
FROM [1]
COPY app /app
CMD ["/app"]
Drag options to blanks, or click blank then click option'
Ascratch
Balpine
Cubuntu
Ddebian
Attempts:
3 left
💡 Hint
Common Mistakes
Using a full Linux distribution like ubuntu or debian instead of scratch.
Forgetting that scratch is an empty image with no shell.
2fill in blank
medium

Complete the Dockerfile to copy the binary into the scratch image.

Docker
FROM scratch
COPY [1] /app
CMD ["/app"]
Drag options to blanks, or click blank then click option'
Aapp.exe
Bapp
Csrc/app
Dbin/app
Attempts:
3 left
💡 Hint
Common Mistakes
Copying source code instead of the compiled binary.
Using a wrong path that does not exist.
3fill in blank
hard

Fix the error in the Dockerfile to run the binary correctly in scratch.

Docker
FROM scratch
COPY app /app
CMD ["[1]"]
Drag options to blanks, or click blank then click option'
A/app
B/bin/bash
Capp
D/bin/sh
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to run shell commands like /bin/sh or /bin/bash which do not exist in scratch.
Using relative paths instead of absolute paths.
4fill in blank
hard

Fill both blanks to create a minimal Dockerfile that builds a Go binary and uses scratch.

Docker
FROM golang:1.20 AS builder
WORKDIR /src
COPY . .
RUN go build -o [1] .
FROM [2]
COPY --from=builder /src/[1] /app
CMD ["/app"]
Drag options to blanks, or click blank then click option'
Aapp
Bscratch
Cubuntu
Dmain
Attempts:
3 left
💡 Hint
Common Mistakes
Using a full Linux base image instead of scratch for the final image.
Naming the binary incorrectly or inconsistently.
5fill in blank
hard

Fill all three blanks to create a minimal Dockerfile that builds a static Go binary and runs it in scratch.

Docker
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]"]
Drag options to blanks, or click blank then click option'
Aapp
Bscratch
Cmain
Dalpine
Attempts:
3 left
💡 Hint
Common Mistakes
Using alpine or other base images instead of scratch for minimal size.
Not setting CGO_ENABLED=0 for static binaries.