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.

EasyTechnical
95 practiced
Explain the difference between an image tag (for example myapp:latest) and a content-addressable digest (sha256:...). Describe implications of using tags versus digests in deployment pipelines, how to pull images immutably, and how to verify the exact image used in production.
HardTechnical
57 practiced
For each language ecosystem (Go, Java, Python, Node.js), explain the implications of choosing distroless, scratch, or alpine base images for runtime. Consider compatibility, debugging experience, binary dependencies, musl vs glibc differences, and best practices to enable observability such as health checks and logs. Provide a recommended base for each language and justify your choice.
HardTechnical
51 practiced
CI Docker builds are being killed due to out-of-memory conditions during compilation of native modules. List possible mitigation strategies: increasing runner memory or swap, lowering parallelism, splitting build workloads into smaller stages, using more memory-efficient toolchains, and pulling prebuilt artifacts from an artifact repository. For each mitigation, explain trade-offs and when to prefer it.
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
52 practiced
Describe what a multi-stage build is in Dockerfile terms and when you would use it. Provide a short scenario where a multi-stage build substantially reduces the final image size and briefly explain how COPY --from transfers artifacts between stages. Also mention one trade-off of using multi-stage builds in development.

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.