CompTIA Linux+ XK0-006 (V8) Practice Question

You need to distribute a Go web service as a minimal, production-ready container image. The security policy says the image must contain only the statically-linked binary, be based on scratch, and run as the unprivileged UID 1001. Which Dockerfile snippet satisfies all of these requirements?

  • FROM golang:1.22-alpine
    WORKDIR /app
    COPY . .
    RUN go build -o server
    USER 1001
    CMD ["./server"]
    
  • # Stage 1 - build
    FROM golang:1.22-alpine AS build
    WORKDIR /src
    COPY . .
    RUN CGO_ENABLED=0 GOOS=linux go build -o /app/server
    
    # Stage 2 - minimal runtime
    FROM scratch
    COPY --from=build /app/server /server
    USER 1001
    ENTRYPOINT ["/server"]
    
  • # Stage 1 - build
    FROM golang:1.22-alpine AS build
    WORKDIR /src
    COPY . .
    RUN CGO_ENABLED=0 GOOS=linux go build -o /app/server
    
    # Stage 2 - minimal runtime
    FROM scratch
    COPY --from=build /app/server /server
    UID 1001
    ENTRYPOINT ["/server"]
    
  • # Builder
    FROM golang:1.22-alpine AS builder
    WORKDIR /src
    COPY . .
    RUN CGO_ENABLED=0 GOOS=linux go build -o /server
    
    # Runtime (still has OS)
    FROM alpine:latest
    COPY --from=builder /server /server
    USER 1001
    ENTRYPOINT ["/server"]
    
CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Settings & Objectives
Random Mixed
Questions are selected randomly from all chosen topics, with a preference for those you haven’t seen before. You may see several questions from the same objective or domain in a row.
Rotate by Objective
Questions cycle through each objective or domain in turn, helping you avoid long streaks of questions from the same area. You may see some repeat questions, but the distribution will be more balanced across topics.

Check or uncheck an objective to set which questions you will receive.

Bash, the Crucial Exams Chat Bot
AI Bot