InterviewStack.io LogoInterviewStack.io

Docker Image Building and Optimization Questions

Practical knowledge of creating Docker images: writing Dockerfiles, multi-stage builds, optimizing image layers for size and performance, understanding base images, managing dependencies, and best practices for production-ready images. Ability to troubleshoot image build issues and explain decisions made in Dockerfile design.

MediumTechnical
52 practiced
You need to integrate automated image vulnerability scanning into the CI pipeline using a tool like Trivy or Clair. Describe where in the build/test/publish stages you would run scanning, what vulnerability thresholds or policies you would enforce (for example block high/critical), how to handle false positives, and how to automate remediation or alerts for teams.
MediumTechnical
53 practiced
Write a Dockerfile for a Go web application that builds a statically linked binary in a builder stage and produces a minimal final image using scratch or distroless. Assume source is at /go/src/app. Include build flags to reduce binary size and explain how CGO_ENABLED influences the choice of final base image in your justification.
EasyTechnical
71 practiced
Compare 'alpine', 'distroless', and 'scratch' base images. For each, explain pros and cons regarding image size, debugging experience, compatibility with dynamic languages, and musl vs glibc issues. Give one real-world example when you'd choose each base image for production.
MediumTechnical
61 practiced
List and explain practical tactics for minimizing Docker image size and number of layers for production images. Discuss pros and cons of combining RUN commands, using multi-stage builds, using --squash, removing package managers from final images, and using tools like docker-slim. Explain how each approach affects build speed, cacheability, and debuggability.
EasyTechnical
65 practiced
Compare COPY and ADD in Dockerfiles. Provide at least two concrete examples where ADD behaves differently from COPY (for example, remote URL retrieval and auto-extracting local tar archives). Explain why COPY is generally preferred in production Dockerfiles and what security or build-context implications arise from using ADD.

Unlock Full Question Bank

Get access to hundreds of Docker Image Building and Optimization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.