CS FundamentalsHardProduct-company DevOps interview
A Go service's Docker image is 900 MB because it includes the compiler and build tools. Which change gives a small image containing only the binary?
- A. Run apt-get clean at the end of the Dockerfile
- B. A multi-stage build: compile in a builder stage, then COPY --from=builder only the binary into a minimal runtime image
- C. Use docker commit after deleting the tools in a running container
- D. Add the tools folder to .dockerignore
Correct answer: B. A multi-stage build: compile in a builder stage, then COPY --from=builder only the binary into a minimal runtime image
Each instruction adds a layer, so deleting files later does not shrink earlier layers. Multi-stage builds keep the toolchain in a throwaway stage and ship just the artefact, which also reduces the attack surface.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- An engineer runs docker exec into a running container, edits a config file, and later the container is removed and recreated from the same…
- A pipeline builds the application separately for each environment (dev, QA, prod) from the same commit. Which principle does this break…
- According to the Twelve-Factor App methodology, where should a service keep its database URL and API keys that differ between staging and…
- A CI pipeline takes 40 minutes: end-to-end UI tests (30 min) run first, then unit tests (3 min), then linting (1 min). Most failures are…
- A service's SLO is 99.9% of requests succeeding over a 30-day window. For a downtime-based view, what is the monthly error budget in…
- A service has a 99.9% success SLO over 30 days. An incident causes a steady 0.5% error rate. If it continues, how soon will the whole…