All jobs / Full-stack developer / DevOps Basics
Full-stack developer interview question · 1–3 years
The application image is over a gigabyte and takes several minutes to pull on every deploy.
How do you make it smaller, and what should not be in it at all?
The strongest answer
A multi-stage build: compile in a stage that has the toolchain, then copy only the built output and the runtime dependencies into a slim base — source, dev dependencies, caches and credentials stay behind
Why it works
Exactly — the build environment never ships. Smaller images pull faster, start faster and give a scanner less to find.
What a good answer covers
- Build stage, then runtime stage.
- Copy only the built output.
- Deleted layers still weigh.
- No secrets baked into images.
Answers that fall short
- Close, but not the strongest: Delete the build tools and the caches at the end of the Dockerfile so the final image comes out clean
Close, and a file deleted in a later layer is still carried by the earlier one: the image keeps the bytes. - Weak: Switch to a smaller base image; that is where most of the size is coming from
A slim base helps a little; the gigabyte is usually the toolchain, the dependencies and the source you copied in. - Red flag: Bake the production configuration and the API keys into the image so the container starts with everything it needs
Anyone who can pull the image then has the keys, and images are copied to registries, caches and laptops.
Who gets asked this
More DevOps Basics questions
- APM shows fast API spans. Users still wait two seconds after click. How do you see one click in the tracer?
- The pipeline builds the client three times, once per environment, because the API URL is baked in at build…
- A feature flag has been on for everyone for four months. Both code paths are still there. When is the flag…
- Every PR gets a preview URL. The default env still has the production API base. What must a preview deploy…
- Prod: 'submit does nothing'. API dashboards look calm. The SPA error rate ticked up after a mixed deploy…
- API 5xx is 0.1%. Users still report 'save failed' because the SPA cannot reach a new path. Which errors go in…
- Platform wants daily UI deploys and weekly API deploys from the same repo. When may UI and API ship on…
- What would you set up so that the next one does not?